MongoDB Shell
4 results found
-
support try..catch
It does not appear that mongosh supports try..catch. I put catch block around "insertOne"
try {
db.inboxItemCounts.insertOne({
"_id": {
"userId": userDoc.userId
},
"fromUserSummary": [{
"userName": fromUserDoc.userName,
"count": 1
}],
"statusSummary": [{
"status": fromUserDoc.status,
"count": 1
}]
});
}
catch(err) {
// print(err);
if(err.includes("E11000 duplicate key error collection")) {
print("got duplicate key exception");
}
}
and the "E11000 duplicate key error collection" exception was not caught at all.
The script stopped and printed the whole error message.1 vote -
db connection issue
i am trying to connect mongo cloud training database using shell propt, i am getting error as below.
have added my laptop ip, and its approved in the cloud instnace but still getting errorl
C:\Users\pvenket1>mongo "mongodb+srv://sandbox.9k9vj.mongodb.net/sampletraining" --username m001-student --password password: m001-mongodb-basics
MongoDB shell version v4.4.1
connecting to: mongodb://sandbox-shard-00-00.9k9vj.mongodb.net:27017,sandbox-shard-00-01.9k9vj.mongodb.net:27017,sandbox-shard-00-02.9k9vj.mongodb.net:27017/sampletraining?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-s4l3gu-shard-0&ssl=true*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
Error: can't connect to new replica set master [sandbox-shard-00-01.9k9vj.mongodb.net:27017], err: AuthenticationFailed: bad auth : Authentication failed. :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 11 voteCommand has an error.
The correct command is:
mongo “mongodb+srv://sandbox.9k9vj.mongodb.net/sampletraining” —username m001-student —password m001-mongodb-basics
or if you are using mongosh:
mongosh “mongodb+srv://sandbox.9k9vj.mongodb.net/sampletraining” —username m001-student —password m001-mongodb-basics
-
Course M001: please bring back Chapter 0
Please put Chapter 0 (installation of MongoDB Shell and Compass) back into course M001. Subsequent chapters refer to the MongoDB Shell and show it being used, but students have not been stepped through the installation process. This chapter was removed on Sept 29. The Sept 22 instance of the course had the step-by-step installation instructions. Using an IDE is not the same, I want students to get hands on with the Shell and with Compass.
1 voteThis is feedback about the MongoDB University course rather than about the MongoDB Shell and it’s been shared with the university team.
-
when you hit up, even if last command was an error, edit it
The most common use case to hit up on the keyboard is that I had a typo in the last command in the shell. When I hit up now, it goes to the most recent valid command not the most recent command.
What it should do is retype the invalid command I last tried to send, regardless of if it was succesful.
1 vote
- Don't see your idea?