I have a really stupid problem that I
I have a really stupid problem that I cannot solve in the last hour.
I'm trying to use result of image mutation in another action
Here is the mutation
Here is the callsite code
I'm getting error
How I can pass the _id value that I got from one mutation into another through the action?
I'm trying to use result of image mutation in another action
Here is the mutation
export default mutation(async ({ db, auth }, project: Id<"projects">, url: string): Promise<Document<"images">> => {
const user = await getCurrentUser(db, auth);
const id = await db.insert("images", {
project: project,
url: url,
});
const val = await db.get(id);
if (val == null) {
throw new Error(`Was not able to query the image ${id} after inserting`)
}
return val;
});export default mutation(async ({ db, auth }, project: Id<"projects">, url: string): Promise<Document<"images">> => {
const user = await getCurrentUser(db, auth);
const id = await db.insert("images", {
project: project,
url: url,
});
const val = await db.get(id);
if (val == null) {
throw new Error(`Was not able to query the image ${id} after inserting`)
}
return val;
});Here is the callsite code
var images = []
const image = await runMutation("newImage", project_id, "https://dummyimage.com/300.png/09f/fff");
images.push(image._id)
const generation = {
images: images,
}
const createdGeneration = await runMutation("storeGeneration", generation);var images = []
const image = await runMutation("newImage", project_id, "https://dummyimage.com/300.png/09f/fff");
images.push(image._id)
const generation = {
images: images,
}
const createdGeneration = await runMutation("storeGeneration", generation);I'm getting error
failure
Field name $id starts with a '$', which is reserved.
at validateObjectField (../../node_modules/convex/src/values/values.ts:259:2)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:480:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:481:2)
at <anonymous> (../../node_modules/convex/src/values/values.ts:433:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:431:29)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:481:2)
at <anonymous> (../../node_modules/convex/src/values/values.ts:433:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:431:29)failure
Field name $id starts with a '$', which is reserved.
at validateObjectField (../../node_modules/convex/src/values/values.ts:259:2)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:480:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:481:2)
at <anonymous> (../../node_modules/convex/src/values/values.ts:433:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:431:29)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:481:2)
at <anonymous> (../../node_modules/convex/src/values/values.ts:433:4)
at convexToJsonInternal (../../node_modules/convex/src/values/values.ts:431:29)How I can pass the _id value that I got from one mutation into another through the action?
