Bulk deletes and indexes
this definitely feels a bit wrong. do I mass delete like this?
3 Replies
Hi there are a couple things that stick out with this:
1. Your query isn't actually using the index to filter the query. To actually use the expires index you need to use the second parameter to
withIndex
. https://docs.convex.dev/database/indexes/#querying-documents-using-indexes
2. Second, though the delete loop will work. A slightly better pattern is to use the map
with Promise.all
pattern as shown for a sub query here: https://docs.convex.dev/tutorial/client#use-the-new-index-to-query-likes-data2: Convex and your app | Convex Developer Hub
Learn how to connect your project to Convex and quickly build out new fullstack features
Indexes | Convex Developer Hub
Indexes are a data structure that allow you to speed up your
oh sh- I completely missed the first point. sometimes I am terrible at reading docs, sorry :KaimonNotLikeThis:
No need to apologize! I am glad you asked and hopefully learned something. 🙂