dsanel / mongoose-delete

Mongoose Soft Delete Plugin
MIT License
346 stars 101 forks source link

Transactions on document methods #145

Open nicholasfoden opened 1 year ago

nicholasfoden commented 1 year ago

Currently I cannot see a way to perform a delete() on a document using a transaction.

Would it be possible to add an options object to the arguments in the same way mongoose's remove method currently does?

Proposed example usage

async function myRemoveMethod(myQuery, mySession) {
    const mydoc = await myModel.findOne(myQuery).session(mySession)
    mydoc.delete(deletedBy, { session: mySession }, callback)
}

Thanks for looking at this issue 🙏

Yuniac commented 5 months ago

Currently I cannot see a way to perform a delete() on a document using a transaction.

Would it be possible to add an options object to the arguments in the same way mongoose's remove method currently does?

Proposed example usage

async function myRemoveMethod(myQuery, mySession) {
    const mydoc = await myModel.findOne(myQuery).session(mySession)
    mydoc.delete(deletedBy, { session: mySession }, callback)
}

Thanks for looking at this issue 🙏

How about this?

 await myModel.delete(myQuery).session(session) <-