Questions tagged [mongo-shell]

The mongo shell is an interactive JavaScript shell for MongoDB, and is part of all MongoDB distributions. This section provides an introduction to the shell, and outlines key functions, operations, and use of the mongo shell.

Most examples in the MongoDB Manual use the mongo shell; however, many drivers provide similar interfaces to MongoDB.

FAQ

713 questions
0
votes
1 answer

MongoDb shell error. Not able to type commands into the shell

I have MongoDB installed on Windows 10. The server is running. The problem is, when I open the mongo shell, I can't type any commands after this: MongoDb shell version: 3.2.6 Connecting to: test See screenshot image: What is the problem? I need to…
user4296898
0
votes
1 answer

MongoDB connecting to authenticationdatabase using shell command

When i connect using from the OS shell, mongo --port 27017 -u "testusr" -p "testpwd" --authenticationDatabase "testdb" Instead of switching taking me to testdb, it always logs me into test database? What I am missing…
NSN
  • 740
  • 3
  • 9
  • 26
0
votes
1 answer

How to update a mongodb object using multiple selection criteria

My schema structure looks something like this: { "__v":0, "_id":ObjectId("5708423e897db8255aaaa9dd"), "podId":169400000005, "env":[ { "type":"1", "id":3852000000035, …
sengakae
  • 39
  • 7
0
votes
0 answers

forEach insertion into MongoDb using Node.js / Bulk insertion using a template

I'm trying to bulk insert thousands of entries into Mongo, what I'm looking for is some sort of way to define a template and only change 1 / multiple variables in that document instead of sending thousands of huge documents that are actually the…
Eek
  • 1,740
  • 1
  • 15
  • 24
0
votes
0 answers

mongo installation and data in different locations

I installed mongodb in usr/local/mongodb but my data is in my project directory desktop/root/data/db I want to use mongo shell to look at my data. If I run usr/local/mongdb/bin/mongo will this show me the data in my project/data/db directory? or is…
Abdul Ahmad
  • 9,673
  • 16
  • 64
  • 127
0
votes
1 answer

'more' in Mongo shell

I would like to know how to output a large document using something like unix's more command in a Mongo shell. I have a large document that I want to inspect, but it quickly fills my terminals maximum height. As a result I cannot see the beginning…
mc9
  • 6,121
  • 13
  • 49
  • 87
0
votes
0 answers

Get mongo autocompletion options in nodejs

In a MongoDB shell when I hit the tab key twice you get all the available options for autocompletion. Is there a way to get these options inside NodeJS?
King Julien
  • 10,981
  • 24
  • 94
  • 132
0
votes
1 answer

How to increase 'db.collection.insert()' batch insertion speed of 100K MongoDB objects

On my Ubuntu server I have a Ruby on Rails app that relies on MongoDB. I often use Mongoid to inject objects into the DB, but when injecting large amounts of object I compile a huge array of hashes and inject it with the mongo Shell method…
Cjoerg
  • 1,271
  • 3
  • 21
  • 63
0
votes
1 answer

MongoDB update ObjectId field

I have a document that has an attribute which is an ObjectId. For example anchor field in the code below: { "__v" : 0, "_id" : ObjectId("5654d896481c5186ddaf4481"), "anchor" : ObjectId("565480e5481c5186ddaf446c"), "base_url" :…
Sanandrea
  • 2,112
  • 1
  • 27
  • 45
0
votes
1 answer

MongoDB projection referenced document

I have Order document like this: { "_id" : ObjectId("55fdd76fe4b08bcb851be855"), "customer" : DBRef("customer", ObjectId("55fdd76fe4b08bcb851be853")) } And I would like to "printout" names of referenced customer like this: db.order.find({},…
svobol13
  • 1,842
  • 3
  • 25
  • 40
0
votes
0 answers

MongoDb script : Cannot compare two types correctly

I have a mongoDB script. db = connect("localhost:27017/metaiot"); var numbers = db.trips.find({trips :{$elemMatch : {"tripON":false}}}); numbers.forEach(function(setter) { for(var index in setter.trips){ if(setter.trips[index]._id ===…
Saras Arya
  • 3,022
  • 8
  • 41
  • 71
0
votes
2 answers

mongodb find element within a hash within a hash

I am attempting to build a query to run from Mongo client that will allow access to the following element of a hash within a hash within a hash. Here is the structure of the data: "_id" : ObjectId("BSONID"), "e1" : "value", "e2" : "value", "e3" :…
Jeff Brown
  • 11
  • 2
0
votes
0 answers

Embedded MongoDB in Spring Boot App can't connect with Mongo shell

I am running a Spring Boot app that has MongoDB embedded in it. When I start the app, MongoDB starts and a DB called 'testdb' is created. If I launch a mongo shell and do 'show dbs', 'testdb' is not listed. If I use Postman to POST data to…
gohmer
  • 55
  • 1
  • 13
0
votes
1 answer

Mongo shell query timing out at 90 seconds

I am using mongodb via the mongo shell to query a large collection. For some reason after 90 seconds the mongo shell seems to be stopping my query and nothing is returned. I have tried the following two commands but neither will return anything. …
user2263572
  • 5,435
  • 5
  • 35
  • 57
0
votes
1 answer

How to start mongo on debian Debian 8.1

I have debian os installed on my computer. Distributor ID: Debian Description: Debian GNU/Linux 8.1 (jessie) Release: 8.1 Codename: jessie I have followed this toturial to Install MongoDB on Debian install mongo db on my computer. Mongodb…
Gagan
  • 573
  • 8
  • 25