I'm trying to do db.createCollection from Nodejs I'm not getting any error, however, the same command is running in node command window it is throwing COllectionName already exists?
And it is ok to have createCollection command in insert method.
Sample command window query:
=> runs only one and throws error on second run:
db.createCollection("myCollection", function(err, coll){})
The same query doesn't throw any error when running from Nodejs MongoDB driver?
Is it good practice to have createCollection into mine save method(API) reason for asking because it already been created on the first hit of API, so if another time mine API will hit this code again run the same command? Do we need to check if that collection exists if not then only create it?