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
2 answers

PHP and Mongo: Searching subdocuments with custom ID

I have created a "params" collection in Mongo with the following structure: { "_id" : "id1", "list" : [ { "type" : "type1", "subtypes" : [ "id1 subtype11", "id1 subtype12" ] } { …
jfabian
  • 19
  • 1
  • 5
0
votes
1 answer

Windows Powershell - Simplest way to run a bunch of commands and save output

In Windows Powershell, I want to make a script that runs a bunch of commands in succession. Like so: mongo a.js > aout.txt mongo b.js > bout.txt ... I'm using PowerShell to get access to the linux like > command. But I can't figure out how to…
Snæbjørn
  • 10,322
  • 14
  • 65
  • 124
0
votes
1 answer

Differences between MongoDB Shell Scripting and JavaScript?

Since this is for a homework assignment I do not want to post my code because it essentially gives a solution. I can post some generic snippets. I am going to start off by saying I am new to javascript and Mongo, and basically learned them in a few…
dspiegs
  • 548
  • 2
  • 9
  • 24
0
votes
1 answer

mongodb geoSpatial query doesn't work

I'm trying to fetch records within a specific radius in km/miles. mongodb 2d index: db.collection.ensureIndex({locaction:"2d"}) a record in the collection has the indexed key: "location" : { "longitude" : 34.791592164168, "latitude" : 32.0516908…
Ranco
  • 893
  • 2
  • 13
  • 43
0
votes
2 answers

Trouble connecting to Mongo Server using Mongo Shell

I ampretty new to Mongo shell and I am trying to switch the server using shell. My current server is of course localhost. I am trying to connect to someserver and the command that I am using for this is basically mongodb://someserver I also…
Lost
  • 12,007
  • 32
  • 121
  • 193
0
votes
1 answer

Connecting to mongos router from Visual Studio 2010 application

I am somewhat new to MongoDB and this might be a silly thing to ask but I'm trying to set up a sharded cluster. I have two mongods running on two different machines, say A and B, on ports 10000 and 20000 respectively. On machine A itself, I have…
-1
votes
1 answer

MongoDB : mongo, mongos, mongosh, mongod

What are the key differences among : mongo mongos mongosh mongod I've tried many websites but didn't get clear explanations for these.
balajirai
  • 19
  • 2
-1
votes
1 answer

Can't run mongo command on windows

I tried t to set up Community MongoDB on my windwos pc. I followed the installation process and tried to set up the environment variables. I copied the pathes from my explorer, so the pathes should be correct. screenshot of my env Nonetheless I…
konsky
  • 1
  • 1
-1
votes
1 answer

mongodb installation in pc

I install mongodp from its web but when its complete its not showing anything i can follow my teacher but in c mongodb 6.0 bin mongodb its not opened but in mongosh its work proper it show the version of mongodb and version of mongosh and show…
-1
votes
1 answer

Mongodb Aggregate - How can i filter an array by multilpe array indexes?

I have a huge array and I need to get only array indexes that are multiple by 12. I thought using $filter, but I'm struggling in the cond parameter. I'm using aggregate because there is more stuff that i need to do, but I'm stuck in this filter…
-1
votes
2 answers

How do I configure NestJS to run mongosh scripts

I have the need to dynamically create mongo databases when a new user is registered on a SaaS platform. How do I configure NestJS to run the scripts needed, to create the database, as well as how to dynamically connect with database created for each…
-1
votes
1 answer

How to print/use save() data result mongo shell

I am adding a record in a collection from mongo shell, and its adding successfully, var demoData = db.getCollection('demoCollection').save({ "name": "My Name", "about": "About my self", "createdAt": new Date(Date.now()).toISOString() });…
turivishal
  • 34,368
  • 7
  • 36
  • 59
-1
votes
1 answer

How much of mongo shell command's javascript part executed is on server?

Is all of the javascript part in mongo shell commands executed on the server or on client or is it partial? Let's say I have a command db.mycollection.find({timestamp:{$lt:new Date()}}).forEach(function(doc){ db.mycollection.remove(doc); }) Is…
Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80
-1
votes
3 answers

mongo shell search for value like "/"fubak@drooop.com"/"

I may have let a bug loose on our code that essentially ruined some of our db data. Every now and again we come across a username that has " " in his email so we need to fix this. How can I search for a value like "/"fubak@drooop.com"/" in one field…
ricardoespsanto
  • 1,000
  • 10
  • 34
-1
votes
2 answers

Error while executing mapreduce in mongo-shell

The following error occours Thu May 23 07:14:53.437 JavaScript execution failed: map reduce failed:{ "errmsg" : "exception: JavaScript execution failed: TypeError: Cannot read property 'product_category' of undefined near…
1 2 3
47
48