Add overridden findOneAndDelete()
See original GitHub issueWhen I need the document returned from a delete, I could do the following with remove()
:
const doc = await MySchema.remove({ _id: someId }).exec();
// Use doc
But with soft delete, the document is not returned, but instead a sort of status code:
const doc = await MySchema.delete({ _id: someId }).exec();
// doc = { n: 1, nModified: 1, ok: 1 }
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Mongoose overwrite the document rather that `$set` fields
It's "mongoose" that is doing this by adding $set into the "update object" where the standard driver would just pass that object through...
Read more >Mongoose v6.8.2: API docs
An array containing all connections associated with this Mongoose instance. By default, there is 1 connection. Calling createConnection() adds a connection ...
Read more >collection.findOneAndDelete() - MongoDB Stitch
Remove a single document from a collection based on a query filter and return a document with the same form as the document...
Read more >db.collection.insert() — MongoDB Manual
Inserts a document or documents into a collection. The insert() method has the following syntax: db.collection.insert(.
Read more >Collection - Node.js MongoDB Driver API
one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@andreyrd in
v0.5.0
we will have a methoddeleteById
. I hope it will help you to easily use plugin. 😉how can i get deleted document in callback or something ? still work like that :
{ n: 1, nModified: 1, ok: 1 }