Ultra newbie confused by lack of insert error in compass/mongosh

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

Ok, found the docs page I was after:

Also found the ‘test’ db which is where all my inserts seem to have been going, can’t work out how to get them to go to my own webex db instead as yet…

…aha, just found out about connection strings, just needed to add ‘/webex’ to the URL to connect to webex db, kinda obvious when ya think about it!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.