Top "Mongo-shell" questions

The mongo shell is an interactive JavaScript shell for MongoDB, and is part of all MongoDB distributions.

Mongo shell execute query from file and show result

How to execute external file using mongo shell and see the result in console? I have external file, like query.…

mongodb mongo-shell
query in mongo Shell gives SyntaxError: missing : after property

db.movieDetails.find( { year: 2013, imdb.rating: Pg-13, award.wins: 0 }, { title: 1, _id: 0 } ).pretty(); The mongo shell returns this error 2016-08-13…

mongodb mongodb-query mongo-shell
Loop through all Mongo collections and execute query

First of, I'm quite new to mongodb. Here's my question I've not been able to find a solution to. Let's …

javascript mongodb mongodb-query mongo-shell
How to use a for loop in the mongodb shell?

How can i use a for loop in the mongo db shell? My attemps are stucking at this point: for (…

mongodb mongodb-query aggregation-framework mongo-shell mongodb-aggregation
How to clear console in MongoDB

While using Mongodb console or shell sometimes my screen is cluttered with a lot of previous output which I do …

mongodb mongo-shell
MongoDb explain failed: "unknown top level operator: $query"

I'm trying to obtain explain from quite simple query. It uses posts collection with following schema: > db.posts.findOne() { "_…

mongodb mongo-shell
How to copy and paste text in MongoDB shell

How to copy and paste text in MongoDB shell? I tried Ctrl+C and Ctrl+V but it didn't work. …

mongodb mongo-shell
Saving the result of a MongoDB query

When doing a research in mongo shell I often write quite complex queries and want the result to be stored …

mongodb mongo-shell
MongoDB error: Cannot use 'commands' readMode, degrading to 'legacy' mode

So I was developing a project using mongo and I got an error after executing the code: db.usercollection.insert({ "…

mongodb mongo-shell
How can I print document in cursor.ForEach?

I've defined some simple cursor as find() on some collection. cursor = db.students.find() Student has following schema: "_id" : 19, "name" : "…

mongodb mongodb-query mongo-shell