17 Replies
show your code
and the problem
i just want a simple update user function
take a user schema
import { partial } from "convex-helpers/validators;
and update it
one thats partial
show me code
i will go toilet in mean time add code
installed it, partial doesnt exist
the code is dead simple
export const updateUser = mutation({
args: {
data: v.optional(),
},
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,
})
},
})
its not even about my code here lol
ok this works now
weirdly
actually no
all fields are now required
show me also your userSchema
its just a v.object
if you make args partial, and the userschema is required, it wouldnt work just to let you know
cc @Wayne @Michal Srb
i guess more of a reason to fully support zod for schemas, or improving the
v
one
ill just create a schema thats all optional
cant waste my time on this
actually its even better
bc not all fields are updatable
so its okimport { partial } from "convex-helpers/validators"
that looks right
nice
Avoid tagging staff unless specifically instructed.
still getting an error:
god dammit
ill just go with my previous approach
relax š
where do you get this error
i need your userschema,,,your functions, and where is your error
it shouldnt be so hard š
fucking exactly
š
its ok tho
its just three fields for now
what you mean three fields