vors
vors3y ago

Document creation type

What's the correct way to re-use my schema elements in the functions? I'm trying to use them as is and for example insert them, but running into problems that there are also _id, _creationTime fields, that I'd like to auto-populate. Concretely here is a mutation I'd like to call
export default mutation(async ({ db, auth },
generation_id?: Id<"generations">,
new_generation?: Document<"generations">) => {
export default mutation(async ({ db, auth },
generation_id?: Id<"generations">,
new_generation?: Document<"generations">) => {
And here is the callsite
const generation = {
project: project_id,
// more-fields
}
await runMutation("storeGeneration", undefined, generation);
const generation = {
project: project_id,
// more-fields
}
await runMutation("storeGeneration", undefined, generation);
I'm getting
_id, _creationTime are missing fields
_id, _creationTime are missing fields
2 Replies
lee
lee3y ago
@alexcole may have a better idea, but i wonder if Omit<Document<"generations">, "_id"|"_creationTime"> would work oh i believe you can import WithoutSystemFields from convex/server and then do WithoutSystemFields<Document<"generations">>
vors
vorsOP3y ago
oh great, let me try that unfortuately cannot use because of the id -> string hydration issue discussed in another thread

Did you find this page helpful?