FyF
Convex Community5mo ago
2 replies
Fy

How do i run internalMutations in nodejs?

import { internalMutation } from "../_generated/server";
import { participantEntry } from "../schema";

export const upsertParticipant = internalMutation({
  args: participantEntry,
  handler: async (ctx, args) => {
    const exists = await ctx.db
      .query("entries")
      .withIndex("byGroupId", (q) => q.eq("groupId", args.groupId))
      .unique();

    if (exists) return true;

    await ctx.db.insert("participantEntry", args);
    return true;
  },
});

btw, I am in persistent nodejs environment.
Was this page helpful?