vexport const updateUser = mutation({
args: {
data: v.optional(userSchema),
},
handler: async (ctx, args) => {
const userId = await getAuthUserId(ctx)
if (userId === null) {
throw new ConvexError('Unauthorized')
}
if (!args.data) {
return
}
await ctx.db.patch(userId, {
...args.data,
})
},
})/**
* partial helps you define an object of optional validators more concisely.
*
* e.g. `partial({a: v.string(), b: v.number()})` is equivalent to
* `{a: v.optional(v.string()), b: v.optional(v.number())}`
*
* @param obj The object of validators to make optional. e.g. {a: v.string()}
* @returns A new object of validators that can be the value or undefined.
*/
export const partial = (obj) => {
return Object.fromEntries(Object.entries(obj).map(([k, vv]) => [
k,
vv.isOptional === "optional" ? vv : v.optional(vv),
]));
};Type '{ name: VString<string | undefined, "optional">; email: VString<string | undefined, "optional">; username: VString<string | undefined, "optional">; ... 7 more ...; lang: VUnion<...>; }' is not assignable to type 'Validator<any, OptionalProperty, any>'.ts(2322)