Standalone deployment ===================== Using MognoDB 5.0 ----------------- > db.createCollection("coll1") { "ok" : 1 } > db.createCollection("coll1") { "ok" : 0, "errmsg" : "Collection already exists. NS: mydb.coll1", "code" : 48, "codeName" : "NamespaceExists" } > db.coll1.insert({ "name": "Antonio" }) WriteResult({ "nInserted" : 1 }) > db.createCollection("coll1") { "ok" : 0, "errmsg" : "Collection already exists. NS: mydb.coll1", "code" : 48, "codeName" : "NamespaceExists" } > db.coll1.createIndex({ "idx": 1 } ) { "numIndexesBefore" : 1, "numIndexesAfter" : 2, "createdCollectionAutomatically" : false, "ok" : 1 } > db.coll1.createIndex({ "idx": 1 } ) { "numIndexesBefore" : 2, "numIndexesAfter" : 2, "note" : "all indexes already exist", "ok" : 1 } Summary: * Creating a collection of which an empty collection already exists: { "ok" : 0, "errmsg" : "Collection already exists. NS: mydb.coll1", ... } * Creating a collection of which a non empty collection exists: { "ok" : 0, "errmsg" : "Collection already exists. NS: mydb.coll1", ... } * Creating an index that already exists: { "ok" : 1, "note" : "all indexes already exist", ... } Using MognoDB 3.6.23 -------------------- > db.createCollection("coll1") { "ok" : 1 } > db.createCollection("coll1") { "ok" : 0, "errmsg" : "a collection 'mydb.coll1' already exists", "code" : 48, "codeName" : "NamespaceExists" } > db.coll1.insert({ "name": "Antonio" }) WriteResult({ "nInserted" : 1 }) > db.createCollection("coll1") { "ok" : 0, "errmsg" : "a collection 'mydb.coll1' already exists", "code" : 48, "codeName" : "NamespaceExists" } > db.coll1.createIndex({ "idx": 1 } ) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.coll1.createIndex({ "idx": 1 } ) { "numIndexesBefore" : 2, "numIndexesAfter" : 2, "note" : "all indexes already exist", "ok" : 1 } Summary: * MongoDB 5.0 and 3.6 have the same behavior Personal conderations --------------------- * When an entity already exist, mongod should return ok: 1 with a note, not an error (as for index creation)