oscklmO
Convex Community3y ago
3 replies
oscklm

Data in db.patch() gets overwritten, even though its not defined?

Hey, when using db.patch() and passing in the args i wanna patch from, one of my fields in this case thumbnailId and thumbnailUrl gets removed? Even though they arent defined, so i would expect that they get ignored?

I might be overlooking something very obvious, but have been tryna fix this for a bit now without luck.

export const updateDetails = mutation({
  args: {
    videoId: v.id('videos'),
    title: v.optional(v.string()),
    description: v.optional(v.string()),
    tags: videoSchema.tags,
    category: videoSchema.category,
  },
  handler: async (ctx, args) => {
    return await ctx.db.patch(args.videoId, {
      snippet: {
        title: args.title,
        description: args.description,
      },
      tags: args.tags,
      category: args.category,
    })
  },
})
Was this page helpful?