I want to check if a collection exist in Node.js. I use the db.collectionNames to get the names list in the db but nothing happened. The code:
connectDB(DBUR
Are you using >2.0 version of the driver?
If so, you will need to use listCollections instead - this is one of the changes in the update from 1.x
Something like:
db.listCollections().toArray(function(err, collections){ //collections = [{"name": "coll1"}, {"name": "coll2"}] });