Hi,
I have just installed mongodb on windows10 and am planning to use it as the backend for a node.js based server project I am working on.
Installation went well and compass looks very nice so far but I find I’m unable to insert data using the mongosh shell, although no error is generated AFAICT.
eg: I’ve created a ‘webex’ database with a single ‘users’ collection and am attempting to insert data in the mongosh shell via:
db.runCommand(
{
insert: "users",
documents: [ { _id: 1, user: "abc123", status: "A" } ]
}
)
mongosh comes back with:
{ n: 1, ok: 1 }
but no data appears to have been inserted into the users collection.
I can insert data using the compass UI no problems so I at least know it’s possible!
I’m thinking maybe I’m missing a ‘use db’ or similar somewhere, but if so I’m surprised by the lack of an errors.
I am working from the docs here (which is where I end up after following all the ‘deprecated’ insert links!):
I am trying to stick with ‘server’ as opposed to ‘mongosh’ commands as I assume I’ll have to use them from node.js code so just want to learn the basics, but haven’t been able to find an index of ‘server only’ commands - the docs seem to be a bit all over the place so far.
Bye!
Mark