Gorka CesiumG
Convex Community3y ago
2 replies
Gorka Cesium

How to use args instead of Doc type in a mutation?

Currently I'm doing this with a type params so I can type the employee arg.
import { WithoutSystemFields } from 'convex/server';
import { Doc } from './_generated/dataModel';
import { mutation } from './_generated/server';

type params = {
  employee: WithoutSystemFields<Doc<'employees'>>;
};
export default mutation(async ({ db }, { employee }: params) => {
  try {
    db.insert('employees', employee);
  } catch (e) {
    console.log(e);
  }
});



How can I do this with the new argument validation https://docs.convex.dev/functions/args-validation ?
Argument validators ensure that queries,
Was this page helpful?