#[Convex Ents] Cannot use insert after adding rules

5 messages · Page 1 of 1 (latest)

obtuse arch
#

I added a custom queryCtx and mutationCtx to use rules and now I cannot longer use insert.

async function queryCtx(baseCtx: QueryCtx) {
  const ctx = {
    db: baseCtx.db as unknown as undefined,
    skipRules: { table: entsTableFactory(baseCtx, entDefinitions) },
  };
  const entDefinitionsWithRules = getEntDefinitionsWithRules(ctx as any);
  const table = entsTableFactory(baseCtx, entDefinitionsWithRules);
  return { ...ctx, table };
}

async function mutationCtx(baseCtx: QueryCtx) {
  const ctx = {
    db: baseCtx.db as unknown as undefined,
    skipRules: { table: entsTableFactory(baseCtx, entDefinitions) },
  };
  const entDefinitionsWithRules = getEntDefinitionsWithRules(ctx as any);
  const table = entsTableFactory(baseCtx, entDefinitionsWithRules);
  return { ...ctx, table };
}
    await ctx
      .table("privateChats")
      .insert({ users: [newUser._id],
        // TS2339: Property insert does not exist on type
 support: false });
  },
idle jay
#

Your code:

async function mutationCtx(baseCtx: QueryCtx) {

Should be:

async function mutationCtx(baseCtx: MutationCtx) {

obtuse arch
#

Oh no

#

I'm so sorry

#

For real