We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7dd314 commit 7cde40bCopy full SHA for 7cde40b
1 file changed
apps/backend-convex/functions/threads/mutate.ts
@@ -36,7 +36,13 @@ export const del = mutation({
36
37
await assertThreadAccess(ctx, { thread, lockerKey: args.lockerKey })
38
39
+ const messages = await ctx.db.query('messages')
40
+ // Use this index because its likely to be cached
41
+ .withIndex('by_thread_and_timestamp', q => q.eq('threadId', args.threadId))
42
+ .collect()
43
+
44
await ctx.db.delete(args.threadId)
45
+ await Promise.all(messages.map(message => ctx.db.delete(message._id)))
46
},
47
})
48
0 commit comments