find all and delete mongoose code example

Example 1: create document mongoose

var Tank = mongoose.model('Tank', yourSchema);

var small = new Tank({ size: 'small' });
small.save(function (err) {
  if (err) return handleError(err);
  // saved!
});

// or

Tank.create({ size: 'small' }, function (err, small) {
  if (err) return handleError(err);
  // saved!
});

// or, for inserting large batches of documents
Tank.insertMany([{ size: 'small' }], function(err) {

});

Example 2: mongoose remove data

Remove is deprecated - use delete
Update for Mongoose v5.5.3 - remove() is now deprecated.
Use deleteOne(), deleteMany() or findOneAndDelete() instead.

Tags:

Misc Example