Questions tagged [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 https://dba.stackexchange.com.

MongoDB is a widely used, general-purpose, document-oriented database with a multitude of features including replication for redundancy and high availability and sharding for horizontal scaling.

The MongoDB Community Edition database server and tools are source-available under Server Side Public License (all versions released after October 16, 2018) or open-source under AGPL v3.0 license (versions released prior to October 16, 2018). Commercial Licenses are also available from MongoDB, Inc.

MongoDB offers a powerful query language, MQL, and provides the Aggregation Framework and Map/Reduce for even more complex queries. MongoDB uses the BSON format for storing data and the MongoDB Wire Protocol for communication between client drivers and the MongoDB server. Officially supported Drivers and Client Libraries are available for most popular programming languages, and there are also Community Supported Drivers which offer alternative implementations and support for further programming languages.

The latest MongoDB server releases can be installed via common packaging systems or downloaded as binary archives from mongodb.com.

The current production release series of MongoDB is 4.4. It is generally recommended to stay current with the latest minor release of a production release series (e.g. 4.4.x) to take advantage of bug fixes and backward-compatible improvements. For more information on the versioning scheme used by the server, see MongoDB Version Numbers.

FAQ

MongoDB Community Forums are the official home for community discussion, product/driver announcements, and introductions.

For help with data modeling (schema design), check out the Data Models documentation page, the Building with Patterns blog series, and M320: Data Modeling course at MongoDB University.

For information on MongoDB Security, view the Security section of the MongoDB Manual which includes a MongoDB Security Checklist.

MongoDB, Inc. (the company behind MongoDB) provides archives of many presentations from their events such as conferences and webinars. They also develop a number of related tools and services including MongoDB Cloud Manager, MongoDB Ops Manager, MongoDB Atlas, and MongoDB Compass.

Useful links

Related Tags

Initial Release:

Feb 11, 2009

Latest Production Release Series:

4.4 (July 30, 2020 - Release notes)

Books

148476 questions
1607
votes
44 answers

How to query MongoDB with "like"

I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How can I achieve the same in MongoDB? I can't find an operator for like in the documentation.
Freewind
  • 177,284
  • 143
  • 381
  • 649
1086
votes
15 answers

"Large data" workflows using pandas

I have tried to puzzle out an answer to this question for many months while learning pandas. I use SAS for my day-to-day work and it is great for it's out-of-core support. However, SAS is horrible as a piece of software for numerous other…
Zelazny7
  • 35,102
  • 16
  • 63
  • 76
881
votes
20 answers

How do I drop a MongoDB database from the command line?

What's the easiest way to do this from my bash prompt?
coffee-grinder
  • 25,040
  • 19
  • 53
  • 81
800
votes
22 answers

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?
coffee-grinder
  • 25,040
  • 19
  • 53
  • 81
754
votes
6 answers

MongoDB vs. Cassandra

I am evaluating what might be the best migration option. Currently, I am on a sharded MySQL (horizontal partition), with most of my data stored in JSON blobs. I do not have any complex SQL queries (already migrated away after since I partitioned my…
ming yeow
  • 25,786
  • 31
  • 111
  • 172
746
votes
14 answers

Query for documents where array size is greater than 1

I have a MongoDB collection with documents in the following format: { "_id" : ObjectId("4e8ae86d08101908e1000001"), "name" : ["Name"], "zipcode" : ["2223"] } { "_id" : ObjectId("4e8ae86d08101908e1000002"), "name" : ["Another ", "Name"], …
emson
  • 8,015
  • 4
  • 19
  • 27
659
votes
7 answers

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. For example, I need a solution to create dynamic tables. So users can create tables with columns and rows. I think either MongoDB or…
Luke101
  • 56,845
  • 75
  • 204
  • 330
590
votes
13 answers

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 records where this array IS NOT empty. I've googled around, but strangely enough I haven't found much on this. I've read into the $where…
skerit
  • 17,691
  • 22
  • 92
  • 138
588
votes
15 answers

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 from beginning. How can I get the last N records in mongodb? Edit: also I want the returned result ordered from less recent to most recent, not…
Bin Chen
  • 54,865
  • 51
  • 136
  • 180
576
votes
10 answers

MongoDB relationships: embed or reference?

I'm new to MongoDB--coming from a relational database background. I want to design a question structure with some comments, but I don't know which relationship to use for comments: embed or reference? A question with some comments, like…
Freewind
  • 177,284
  • 143
  • 381
  • 649
570
votes
10 answers

Find document with array that contains a specific value

If I have this schema... person = { name : String, favoriteFoods : Array } ... where the favoriteFoods array is populated with strings. How can I find all persons that have "sushi" as their favorite food using mongoose? I was hoping for…
Ludwig Magnusson
  • 12,476
  • 10
  • 32
  • 49
538
votes
8 answers

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's difficult to read, especially with nested arrays and documents.
raffian
  • 28,859
  • 25
  • 95
  • 164
536
votes
19 answers

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 comments) and I want to pull all the comments with pid=444 along with the user info for each. comments { uid:12345, pid:444, comment="blah"…
The Unknown
  • 17,346
  • 29
  • 69
  • 91
534
votes
13 answers

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. Something like: db.users.findOne({$contains:{"username":"son"}}) Is that possible?
johnny
  • 6,805
  • 6
  • 23
  • 35
525
votes
10 answers

When to use MongoDB or other document oriented database systems?

We offer a platform for video- and audio-clips, photos and vector-grafics. We started with MySQL as the database backend and recently included MongoDB for storing all meta-information of the files, because MongoDB better fits the requirements. For…
aurora
  • 9,411
  • 7
  • 33
  • 51
1
2 3
99 100