I do not understand what’s going on. I never had these issues before. I encountered this behaviour in both the latest 6.x version as well as on 4.2.X (which we use now as we want to use Azure Cosmos DB later on).
I was buffled when I tried to use the following snippet to test our microframework we’re currently building (using the .NET Driver):
db.Books.updateMany({}, {$set: {'newField': true}})
This occurs in both MongoDB Compass as well as DataGrip, both connected to my test database “Test”. This has one collection called “Books” with 10 documents I generated using my test application.
This command does not match any document (which makes no sense since I am using an empty filter), while when I execute the same thing using the .NET driver the field is inserted into all 10 documents.
Now I needed to create a new collection. So I used:
db.createCollection('Books2')
Which should obviously create a collection called “Books2” in my Test database. But all Mongo returns is the following exception:
MongoServerError: db already exists with different case already have: [Test] trying to create [test]
at Connection.onMessage (C:\Users\eisen\AppData\Local\MongoDBCompass\app-1.35.0\resources\app.asar.unpacked\node_modules\@mongosh\node-runtime-worker-thread\dist\worker-runtime.js:1917:3099431)
at MessageStream.<anonymous> (C:\Users\eisen\AppData\Local\MongoDBCompass\app-1.35.0\resources\app.asar.unpacked\node_modules\@mongosh\node-runtime-worker-thread\dist\worker-runtime.js:1917:3096954)
at MessageStream.emit (node:events:394:28)
at c (C:\Users\eisen\AppData\Local\MongoDBCompass\app-1.35.0\resources\app.asar.unpacked\node_modules\@mongosh\node-runtime-worker-thread\dist\worker-runtime.js:1917:3118818)
at MessageStream._write (C:\Users\eisen\AppData\Local\MongoDBCompass\app-1.35.0\resources\app.asar.unpacked\node_modules\@mongosh\node-runtime-worker-thread\dist\worker-runtime.js:1917:3117466)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at Socket.ondata (node:internal/streams/readable:749:22)
at Socket.emit (node:events:394:28)
Why? I clearly am operating ON my databse and try to create a collection as the method name states. Why is it trying to create a new database when I run this command?
Something is awfully off with mongosh. I don’t know why, but so far no command worked as expected while running these via the driver worked just fine.
Can somebody explain me what’s going on? If this is it, we might have to consider seriously moving to a different database system.