Sikarin (Afu)S
Convex Community3mo ago
6 replies
Sikarin (Afu)

Can I skip some filter field in withIndex

Guys I have question about withIndex

schema:
profile: defineTable(profile).index("by_filter", ["gender", "age"])


query:
const gender = "male"
const minAge = 18
const profile = await ctx.db.query("profiles")
     .withIndex("by_filter", q => 
       q.eq("gender", gender)
       q.lte("age", minAge)
     )


but if gender is "everyone"
seem withIndex from "by_filter" is force 1st condition should check "gender" before "age" how can I skip that

this example have only 2 fields but, my filter have about 8 fields, can I skip some field via filter with withIndex

thank you
Was this page helpful?