Questions tagged [mongodb-shell]

The MongoDB shell is a command-line tool for querying and administering MongoDB.

The MongoDB shell is a command-line tool for MongoDB. It allows for querying collections, as well as admin functions like adding users, copying databases, and profiling.

Mongo Command Line

http://cheat.errtheblog.com/s/mongo

115 questions
0
votes
0 answers

Mongodb sharding testing

I have mongodb sharded cluster in my local machine(windows). But I didn't understand how to test this. My configurations are: Replicaset 1: mongod --replSet s0 --dbpath E:/mongo/data/shard0/rs0 --port 37017 --shardsvr mongod --replSet s0 --dbpath…
0
votes
2 answers

Mongodb insert document via shell

I want to perform crud operation on my collection. To automate this, I wrote a script for inserting documents on my collection. This script should basically read the data from a json file and insert it into my db-collection. 'use strict'; const fs…
MarcoLe
  • 2,309
  • 6
  • 36
  • 74
0
votes
1 answer

How can I copy a db mongo to another mongodb instance?

I want to copy my db called users binded by default to localhost:27017 to another bind address. How can I do this?
0
votes
1 answer

--noscripting not preventing scripting

I've started my MongoDB server with the --noscripting option: mongod --dbpath C:\MongoData --noscripting However, I can still load JavaScript files and execute the code in them: > load('/Users/d.banks/Documents/mongo-rocks/hello-world.js') true >…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
0
votes
1 answer

How to delete the document based on ObjectId (_id)

How do I write a MongoDB shell query that will return the documents for all objects created after a specific date? Collections like: { "_id" : ObjectId("59918c9014450171039b7e1f"), "cont_id" : "59918c9014450171039b7e1d", "systemdate" :…
Bharathiraja S
  • 679
  • 4
  • 12
  • 26
0
votes
0 answers

Byte is decreased after mongo copy to another server

I am a newbie to MongoDB. I use mongodb db.copyDatabase command for copying database to another server. After I copy(I got the Ok sign from mongo shell), I found something strange. In my source Server db > show dbs newstrust 13.947GB In…
문승현
  • 21
  • 1
  • 7
0
votes
1 answer

How can I define alias for Mongo Shell

In MongoDB Shell, there is a command edit to inspect/modify the value by your favourite editor specified by EDITOR. But how can I create an alias for edit, such as e ?
ruanhao
  • 4,663
  • 6
  • 28
  • 43
0
votes
0 answers

MongoDB returns different document count, when selecting the data and doing count

I am having strange issue with sharded mongodb, when selecting data and when doing count. I have db.parts.find({"my_key":"123"}); -- I get one result back but when I do db.parts.find({"my_key":"123"}).count(); -- count returns 2 results. I am…
usearch
  • 65
  • 1
  • 13
0
votes
1 answer

Mongodb: Combine $in and $nin

In my collection posts I've documents like this [{ _id : ObjectId("post-object-id"), title : 'Post #1', category_id : ObjectId("category-object-id") }] I need to make some queries where I those a range of posts based on their category_id…
0
votes
2 answers

Slowing down MongoDB shell output for large documents?

I am trying to inspect a document that is larger than the print buffer for the Windows command window. For some queries more allows you to type it for more output. Is there a way to apply this to other commands? For instance I might do…
KDecker
  • 6,928
  • 8
  • 40
  • 81
0
votes
1 answer

How to login with a user with role userAdmin in mongodb

I have mongod server up and running as a service on ubuntu 14.04, i started mongo shell and created a user. db.createUser( { user: "testAdmin", pwd: "12345678", roles: [ { role: "userAdmin", db: "students" } ] } ) after that I…
Puneet Singh
  • 3,477
  • 1
  • 26
  • 39
0
votes
1 answer

Can not add function to mongodb

I don't know when the problem begin. I find that when i create a new function to mongodb, and then run it like this: db.loadServerScripts(); testFun('xxx'); Two errors will occur: SyntaxError: missing } after property list…
yunnysunny
  • 183
  • 1
  • 15
0
votes
1 answer

How to get the list of docs that exist more than 1 time in mongoDB with the same field?

I would like to create a query that will get all the docs with title that exist more than 1 time in mongoDB. lets say that this is my doc: { "itemID" : "AAN88998JJCA", "itemTitle" : "AAAA } { "itemID" : "AAN8BB98JJCA", "itemTitle" :…
USer22999299
  • 5,284
  • 9
  • 46
  • 78
0
votes
3 answers

MongoDB shell: How to remove specific elements in all the collections inside a DB

I would like to remove, in all collections, all coincidences with a regex expression. I need this, because a JSON parser failed in my app at a certain point today, and now the database is corrupted. I could do it by hand, but I have over 100+…
Geiser
  • 1,054
  • 1
  • 12
  • 28
0
votes
2 answers

mongo shell not showing all dbs

Good Day. I've been developing with meteorJS which uses mongodb. No problems there. I've been using the mongo shell to access the database on my dev machine (osx 10.11). This is my first project with mongo and when the shell would load, it would…
dmayo
  • 640
  • 6
  • 16