StarlordS
Convex Community12mo ago
6 replies
Starlord

Index query with "OR" statement

hello,

is there a way to optimize this query using index because "or" statement is not possible in index? this way full table data is fetched and only filtered afterwards.

// Get variations for filtered products
const allProductVariations = await ctx.db
    .query("productVariations")
    .filter(q => 
        q.or(...results.page.map(product => 
            q.eq(q.field("productId"), product._id)
        ))
    )
    .collect();
Was this page helpful?