Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
demo_dropcollection.js:
var MongoClient = require('mongodb').MongoClient; var url = "mongodb://localhost:27017/"; MongoClient.connect(url, function(err, db) { if (err) throw err; var dbo = db.db("mydb"); //Delete the "customers" collection: dbo.dropCollection("customers", function(err, delOK) { if (err) throw err; if (delOK) console.log("Collection deleted"); db.close(); }); });
C:\Users\My Name>node demo_dropcollection.js
Collection deleted