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 6.0. It is generally recommended to stay current with the latest minor release of a production release series (e.g. 6.0.1) 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.

MongoDB has a GUI called MongoDB Compass, which is a powerful GUI for querying, aggregating, and analyzing your MongoDB data in a visual environment. Compass is free to use and source available and can be run on macOS, Windows, and Linux.

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:

6.0 (July 19, 2022 - Release notes)

Books

Articles

174599 questions
1890
votes
46 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
  • 193,756
  • 157
  • 432
  • 708
1178
votes
16 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
  • 39,946
  • 18
  • 70
  • 84
944
votes
15 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
  • 10,005
  • 4
  • 24
  • 27
929
votes
22 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
  • 26,940
  • 19
  • 56
  • 82
898
votes
23 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
  • 26,940
  • 19
  • 56
  • 82
763
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…
meow
  • 27,476
  • 33
  • 116
  • 177
748
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…
Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
722
votes
15 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
  • 8,696
  • 6
  • 25
  • 36
696
votes
13 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
  • 13,964
  • 10
  • 38
  • 53
686
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
  • 63,072
  • 85
  • 231
  • 359
680
votes
16 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
  • 61,507
  • 53
  • 142
  • 183
663
votes
11 answers

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 syntax?
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
630
votes
10 answers

MongoDB relationships: embed or reference?

I want to design a question structure with some comments. Which relationship should I use for comments: embed or reference? A question with some comments, like stackoverflow, would have a structure like this: Question title = 'aaa' content =…
Freewind
  • 193,756
  • 157
  • 432
  • 708
628
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
  • 19,224
  • 29
  • 77
  • 93
585
votes
12 answers

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 delete like so... db.copyDatabase('old_name', 'new_name'); use old_name db.dropDatabase(); Is there a command to rename a database?
Brian Hempel
  • 8,844
  • 2
  • 24
  • 19
1
2 3
99 100