How to wrap the database writer so that `ctx.db.patch` and `ctx.db.insert` run side effects - Convex Community