Mongodb

MongoDB is a scalable, high-performance, open source, document-oriented NoSQL database. It supports a large number of languages and application development platforms. Questions about server administration can be asked on http://dba.stackexchange.com.

59 votes
14 answers
2.5K views
Retrieve only the queried element in an object array in MongoDB collection

Suppose you have the following documents in my collection: { "_id":ObjectId("562e7c594c12942f08fe4192"),

avatar
Clarice
0 1 0 9
asked 07 September, 2021
53 votes
21 answers
334 views
How to execute mongo commands through shell scripts?

I want to execute mongo commands in shell script, e.g. in a script test.sh: #!/bin/sh mongo myDbName db.mycol

avatar
Roger
0 1 0 9
asked 07 September, 2021
59 votes
11 answers
2K views
Update MongoDB field using value of another field

In MongoDB, is it possible to update the value of a field using the value from another field? The equivalent

avatar
Carmelina
0 1 0 9
asked 07 September, 2021
60 votes
19 answers
1.3K views
MongoDB or CouchDB - fit for production?

I was wondering if anyone can tell me if MongoDB or CouchDB are ready for a production environment.

avatar
Boyd
0 1 0 9
asked 07 September, 2021
61 votes
17 answers
1.1K views
Delete everything in a MongoDB database

I'm doing development on MongoDB. For totally non-evil purposes, I sometimes want to blow away everything

avatar
Virgil
0 1 0 9
asked 07 September, 2021
53 votes
15 answers
1.6K views
Find objects between two dates MongoDB

I've been playing around storing tweets inside mongodb, each object looks like this: { "_id" : ObjectId(

avatar
Kristopher
0 1 0 9
asked 07 September, 2021
62 votes
11 answers
1.7K views
How do you query for "is not null" in Mongo?

I would like to execute a following query: db.mycollection.find(HAS IMAGE URL) What should be the correct s

avatar
Lorenzo
0 1 0 9
asked 07 September, 2021
53 votes
28 answers
3K views
Mongod complains that there is no /data/db folder

I am using my new mac for the first time today. I am following the get started guide on the mongodb.org up unt

avatar
Robyn
0 1 0 9
asked 07 September, 2021
60 votes
10 answers
435 views
How do you rename a MongoDB database?

There's a typo in my MongoDB database name and I'm looking to rename the database. I can copy and d

avatar
Adolfo
0 1 0 9
asked 07 September, 2021
59 votes
19 answers
2.8K views
How do I perform the SQL Join equivalent in MongoDB?

How do I perform the SQL Join equivalent in MongoDB? For example say you have two collections (users and comm

avatar
Trudy
0 1 0 9
asked 07 September, 2021
52 votes
8 answers
540 views
Pretty print in MongoDB shell as default

Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it&a

avatar
Percy
0 1 0 9
asked 07 September, 2021
60 votes
14 answers
1.9K views
Checking if a field contains a string

I'm looking for an operator, which allows me to check, if the value of a field contains a certain string.

avatar
Xavier
0 1 0 9
asked 07 September, 2021
52 votes
10 answers
1.3K views
MongoDB relationships: embed or reference?

I'm new to MongoDB--coming from a relational database background. I want to design a question structure w

avatar
Robyn
0 1 0 9
asked 07 September, 2021
54 votes
12 answers
2.4K views
Find document with array that contains a specific value

If I have this schema... person = { name : String, favoriteFoods : Array } ... where the favoriteFo

avatar
Frederick
0 1 0 9
asked 07 September, 2021
51 votes
15 answers
1.8K views
How to get the last N records in mongodb?

I can't find anywhere it has been documented this. By default, the find() operation will get the records

avatar
Bryant
0 1 0 9
asked 07 September, 2021
63 votes
13 answers
1.3K views
Find MongoDB records where array field is not empty

All of my records have a field called "pictures". This field is an array of strings. I now want the newest 10

avatar
Roger
0 1 0 9
asked 07 September, 2021
53 votes
7 answers
600 views
When to use CouchDB over MongoDB and vice versa

I am stuck between these two NoSQL databases. In my project I will be creating a database within a database.

avatar
Margo
0 1 0 9
asked 07 September, 2021
48 votes
14 answers
3K views
Query for documents where array size is greater than 1

I have a MongoDB collection with documents in the following format: { "_id" : ObjectId("4e8ae86d08101908e10

avatar
Benton
0 1 0 9
asked 07 September, 2021
56 votes
22 answers
2.4K views
How can I list all collections in the MongoDB shell?

In the MongoDB shell, how do I list all collections for the current database that I'm using?

avatar
Jeff
0 1 0 9
asked 07 September, 2021
67 votes
20 answers
2.6K views
How do I drop a MongoDB database from the command line?

What's the easiest way to do this from my bash prompt?

avatar
Boyd
0 1 0 9
asked 07 September, 2021