You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lost track due to the high number of schemas that are generated, there are actually default schemas generated for SQL
When fetching data from my DB (e.g. for a table), I include params in my zod object that I use to write SQL queries that include TAKE, SKIP, ORDERBY...etc.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Lost track due to the high number of schemas that are generated, there are actually default schemas generated for SQL
When fetching data from my DB (e.g. for a table), I include params in my zod object that I use to write SQL queries that include
TAKE
,SKIP
,ORDERBY
...etc.So a typical z.object might look like this:
export const searchParamsSchema = z.object({ page: z.number().or(z.string().transform(Number)).default(1), per_page: z.number().or(z.string().transform(Number)).default(10), sort: z.string().optional(), name: z.string().optional(), title: z.string().optional(), category: z.string().optional(), store: z.string().optional(), status: z.string().optional(), priority: z.string().optional(), operator: z.enum(["and", "or"]).optional(), })
Beta Was this translation helpful? Give feedback.
All reactions