-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
This pattern of multi-upsert violates uniqueness constraints on the docs:
async function _saveAll(
ctx: MutationCtx,
perms: WithoutSystemFields<Doc<"perms">>[],
) {
return await asyncMap(perms, async (perm) => {
const existing = await ctx.table("perms").get("id", perm.id);
if (existing === null) {
return await ctx.table("perms").insert(perm);
} else {
return await existing.replace(perm);
}
});
}
This is because the reads happen in concurrent, and then the writes happen. This is not really specific to Ents, but Ents should catch this footgun.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request