zidZ
Convex Community3y ago
12 replies
zid

Complex queries based off of items in an array

I'd like to be able to:

.widthIndex("by_userId_primarySkills_secondarySkills",  q => q.includes("primarySkills", arrayItem))


I have some complex query requirements and the above would help immensely!

But perhaps there's another way to efficiently accomplish this?
I have a
users
table and a separate table
skills

Each skills document has a type field that can hold one of three types
primary
,
secondary
, and
lookingFor
. Each user can have up to 3 primary types/docs, 3 secondary types/docs, and 6 lookingFor types/docs.

With this schema, it's challenging to write a complex query without a lot of application logic and costly ($$) additional reads. But if I could denormalize the data for users to have
users.primarySkills
where primarySkills is an array, and if I could query at the array item level, that would be a seamless solution
Was this page helpful?