How to check if a collection exists in Mongodb native nodejs driver?

I need to check if a collection exists on a certain database and create it if it doesn't. I know that

db.createCollection(collName, {strict:true}, function(error, collection))

checks for existance of collection collName before creating it and sets error object. but I need an independent function to check that.

Leave a Reply

Your email address will not be published. Required fields are marked *