kstulgys
kstulgys10mo ago

Is there a way to delete or update item without using db.delete and db.patch?

I want to delete or update item but lets say I can not use _id
4 Replies
erquhart
erquhart10mo ago
You would query to get the item with whatever data you have - once you query you have the id, then you can delete. Same for patch If you're working with a list, you can async map over the query result to concurrently patch/delete
kstulgys
kstulgysOP10mo ago
I'm writing ConvexAdapter for lucia auth v3
public async deleteSession(sessionId: string) {
const session = await this.db
.query("sessions")
.filter((q) => {
return q.eq(q.field("sid"), sessionId);
})
.unique();
if (session) await this.db.delete(session._id);
}
public async deleteSession(sessionId: string) {
const session = await this.db
.query("sessions")
.filter((q) => {
return q.eq(q.field("sid"), sessionId);
})
.unique();
if (session) await this.db.delete(session._id);
}
Error: this.db.delete does not exist I assume this is because of the "transactional" nature of convex maybe? FYI sessionId is legit sid is something lucia-auth creates
ian
ian10mo ago
You can't delete from within a query - only within a mutation transaction
kstulgys
kstulgysOP10mo ago
Yes, I see, working now

Did you find this page helpful?