much 2 yearn
much 2 yearn
CCConvex Community
Created by much 2 yearn on 3/17/2024 in #support-community
Best practice to get userId from from user user in function
but will
ctx.auth.getUserIdentity()?.subject
ctx.auth.getUserIdentity()?.subject
always return the userId ? So the flow would be : get userId from the auth ( "subject") , query users table with that id (to convert to
Id<"users">
Id<"users">
, then mutate with the returned
user._id
user._id
? thanks for always helping much appreciated @lee
6 replies
CCConvex Community
Created by much 2 yearn on 3/16/2024 in #support-community
Use zod schemas for argument validation
wondering if there is a better way to just just export one zod schema and type
8 replies
CCConvex Community
Created by much 2 yearn on 3/16/2024 in #support-community
Use zod schemas for argument validation
@lee would I have to store the initial schema as a regular object with zod properties then also export a z.object of the same schema?
8 replies
CCConvex Community
Created by much 2 yearn on 3/16/2024 in #support-community
Use zod schemas for argument validation
thanks for the reply btw!
8 replies
CCConvex Community
Created by much 2 yearn on 3/16/2024 in #support-community
Use zod schemas for argument validation
you are right it is a z object that i use for form validation on the front end. What is the best way to reuse this schema to work with convex ?
8 replies
CCConvex Community
Created by much 2 yearn on 3/16/2024 in #support-community
Use zod schemas for argument validation
// FORM TEMPLATE SCHEMAS
export const createTemplateSchema = z.object({
title: z.string().max(25, { message: "Max 25 characters" }).optional(),
goal: z.union([
z.literal("bodybuilding"),
z.literal("powerlifting"),
z.literal("powerbuilding"),
z.literal("mobility"),
z.literal("sport"),
z.literal("general"),
]),
format: z.union([z.literal("split"), z.literal("program")]),
weekLength: z.number().min(1).max(12),
maxWeeks: z.number(),
weeks: z.array(DaySchema),
});
// FORM TEMPLATE SCHEMAS
export const createTemplateSchema = z.object({
title: z.string().max(25, { message: "Max 25 characters" }).optional(),
goal: z.union([
z.literal("bodybuilding"),
z.literal("powerlifting"),
z.literal("powerbuilding"),
z.literal("mobility"),
z.literal("sport"),
z.literal("general"),
]),
format: z.union([z.literal("split"), z.literal("program")]),
weekLength: z.number().min(1).max(12),
maxWeeks: z.number(),
weeks: z.array(DaySchema),
});
8 replies