Tag: mongodb

51 votes
15 answers
1.5K views
How to remove a field completely from a MongoDB document?

{ name: 'book', tags: { words: ['abc','123'], lat: 33,

avatar
Keila
0 1 0 9
asked 07 September, 2021
61 votes
6 answers
1.8K views
Add new field to every document in a MongoDB collection

How can I add a new field to every document in an existent collection? I know how to update an existing docum

avatar
Keila
0 1 0 9
asked 07 September, 2021
56 votes
18 answers
1.2K views
How to secure MongoDB with username and password

I want to set up user name & password authentication for my MongoDB instance, so that any remote access wi

avatar
Kristopher
0 1 0 9
asked 07 September, 2021
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
62 votes
23 answers
2.8K views
How do I update/upsert a document in Mongoose?

Perhaps it's the time, perhaps it's me drowning in sparse documentation and not being able to wrap m

avatar
Rufus
0 1 0 9
asked 07 September, 2021
53 votes
21 answers
335 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
436 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
541 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