emiljanitzek / mongoose-delete-ts

Mongoose Soft Delete Plugin
MIT License
10 stars 4 forks source link

There is no option to bulk delete (hard delete) documents #20

Closed rijin-newage closed 1 month ago

rijin-newage commented 1 year ago

Default Model.deleteMany() function is replaced, so there is no option for hard delete documents. There should be a way to pass force: true option which will do a hard delete.

// Delete multiple object, callback
Model.deleteMany({});

// Delete multiple object (hard), callback
Model.deleteMany({}, { force: true });

Note: Model.remove() is deprecated.

emiljanitzek commented 7 months ago

What is the use-case where you want to use both soft and hard delete for the same model? You could always use the underlying connection to bypass the soft delete for a collection. mongoose.connection.collection(Model.collection.name).deleteMany({})