wrux
wrux
CCConvex Community
Created by wrux on 2/9/2025 in #support-community
Query, filtering array of IDs
I have a jobs schema which has a skills property which is just an array of ID references.
jobs: defineTable({
title: v.string(),
clientId: v.id('users'),
skills: v.optional(v.array(v.id('skills'))),
}).index('by_clientId', ['clientId'])
jobs: defineTable({
title: v.string(),
clientId: v.id('users'),
skills: v.optional(v.array(v.id('skills'))),
}).index('by_clientId', ['clientId'])
In my application, I want to filter by skills. What is the best way to query a set union on skills and my args. I know the following query won't work. I'm just wondering if something like this is possible:
let jobsQuery = ctx.db
.query('jobs')
.filter((q) => q.eq(q.field('status'), args.status))
.filter((q) => {
q.and(q.field('skills'), q.contains(q.field('skills'), args.skills))
});
let jobsQuery = ctx.db
.query('jobs')
.filter((q) => q.eq(q.field('status'), args.status))
.filter((q) => {
q.and(q.field('skills'), q.contains(q.field('skills'), args.skills))
});
37 replies
CCConvex Community
Created by wrux on 2/6/2025 in #support-community
Best solution for checks like unique username
Right now I am building an app with Vite React and zod, react-hook-form. I have a form that does not check uniqueness on the username, but if I add a check, what would be the "best practice"? My Convext backend checks if already exists, I'm just wondering where to add the check on the frontend.
7 replies