Kenni
CCConvex Community
•Created by Kenni on 12/3/2024 in #support-community
How to query items where array field contains a specific value?
I have a paginated query where I need to filter items based on whether an array field contains a specific category ID. Currently, my query only returns items where the array exactly matches
[categoryId]
, but I need it to return items where categoryId
is one of potentially many elements in the array.
Here's my current query:
For example, if I have these items in my database:
When querying for categoryId: "category1"
, I want both items to be returned since they both contain "category1" in their categories array.
Is there a way to achieve this kind of "contains" functionality for array fields in Convex? I need this to work with pagination too.
Any suggestions would be appreciated!4 replies
CCConvex Community
•Created by Kenni on 11/20/2024 in #support-community
Handling "Too many reads" Error During Mass Deletion in Convex
Hello Convex team! 👋
I'm encountering a read limit error while implementing parent-child record deletion in our application. Would appreciate guidance on the best approach.
The Error
Current Implementation
Here's a simplified version of our deletion code:
Specific Questions
1. Read Limit Management
- What's the recommended approach to stay within the 4096 read limit for large deletions?
- Should the deletion be split across multiple mutation calls?
- Is there a way to monitor read count during execution?
2. Batch Processing
- What's the optimal batch size for avoiding read limits?
- Is sequential processing better than parallel (Promise.all) for related tables?
- How should we handle pagination for large-scale deletions?
3. Best Practices
- What's the recommended pattern for deleting deeply nested data structures?
- Should we implement a job system for large deletions?
- Are there specific indexing strategies for optimization?
Current Scale
- Average parent record has:
- 100-200 type A children
- 50-100 type B children
- 500-1000 associated records
- Each child might have 5-10 nested records
What We've Tried
1. Reduced batch size to 50
2. Processed tables sequentially instead of parallel
3. Used indexed queries
Would greatly appreciate guidance on:
1. Most efficient way to structure these deletions
2. Best practices for handling read limits
3. Recommended Convex features for this use case
Thank you! 🙏
7 replies