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
182
votes
37 answers

Couldn't connect to server 127.0.0.1:27017

I'm getting the following error: alex@alex-K43U:/$ mongo MongoDB shell version: 2.2.0 connecting to: test Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 exception: connect failed alex@alex-K43U:/$…
alexchenco
  • 53,565
  • 76
  • 241
  • 413
180
votes
16 answers

Read-only file system when attempting mkdir /data/db on Mac

I am trying to create a new folder in the root directory. I tried all kinds of examples. sudo mkdir /data/db sudo mkdir -p /data/db I keep getting: mkdir: /data: Read-only file system
jalapina
  • 3,962
  • 3
  • 12
  • 19
180
votes
5 answers

MongoDB/NoSQL: Keeping Document Change History

A fairly common requirement in database applications is to track changes to one or more specific entities in a database. I've heard this called row versioning, a log table or a history table (I'm sure there are other names for it). There are a…
Phil Sandler
  • 27,544
  • 21
  • 86
  • 147
180
votes
8 answers

MongoDB vs Firebase

MongoDB vs Firebase What are some quantitative advantages of using Firebase over MongoDB? (not opinions) I know that Firebase is a cloud-based service with its own API, but I feel like Mongo may give me greater control in the long run.
itsclarke
  • 8,622
  • 6
  • 33
  • 50
180
votes
7 answers

Mongoose and multiple database in single node.js project

I'm doing a Node.js project that contains sub projects. One sub project will have one Mongodb database and Mongoose will be use for wrapping and querying db. But the problem is Mongoose doesn't allow to use multiple databases in single mongoose…
pupot
  • 1,841
  • 2
  • 12
  • 7
180
votes
9 answers

What is the difference between save and insert in Mongo DB?

What is the difference between save and insert in Mongo DB? both looks the same db.users.save({username:"google",password:"google123"}) db.users.insert({username:"google",password:"google123"})
user2093576
  • 3,082
  • 7
  • 32
  • 43
180
votes
10 answers

How to sort a collection by date in MongoDB?

I am using MongoDB with Node.JS. I have a collection which contains a date and other rows. The date is a JavaScript Date object. How can I sort this collection by date?
flow
  • 4,828
  • 6
  • 26
  • 41
177
votes
6 answers

Include all existing fields and add new fields to document

I would like to define a $project aggregation stage where I can instruct it to add a new field and include all existing fields, without having to list all the existing fields. My document looks like this, with many fields: { obj: { …
samuelluis
  • 1,771
  • 2
  • 11
  • 3
175
votes
18 answers

mongoError: Topology was destroyed

I have a REST service built in node.js with Restify and Mongoose and a mongoDB with a collection with about 30.000 regular sized documents. I have my node service running through pmx and pm2. Yesterday, suddenly, node started crapping out errors…
dreagan
  • 2,426
  • 6
  • 24
  • 34
174
votes
13 answers

Can I query MongoDB ObjectId by date?

I know that ObjectIds contain the date they were created on. Is there a way to query this aspect of the ObjectId?
Zach
  • 18,594
  • 18
  • 59
  • 68
174
votes
1 answer

mongod, mac os x - rlimits warning

I've been using mongo on my mac os x 10.8 and suddenly yesterday at my logs appeared this warning (and when starting shell it's present too) - WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 Who could explain, what…
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
173
votes
15 answers

Remove by _id in MongoDB console

In the MongoDB console how can I remove a record by id? Here's my collection : [ { "_id" : { "$oid" : "4d512b45cc9374271b02ec4f" }, "name" : "Gazza" }, { "_id" : { "$oid" : "4d513345cc9374271b02ec6c" }, "name" : "Dave", …
Typo Johnson
  • 5,974
  • 6
  • 29
  • 40
173
votes
19 answers

TypeError: ObjectId('') is not JSON serializable

My response back from MongoDB after querying an aggregated function on document using Python, It returns valid response and i can print it but can not return it. Error: TypeError: ObjectId('51948e86c25f4b1d1c0d303c') is not JSON…
Irfan
  • 4,882
  • 12
  • 52
  • 62
172
votes
9 answers

How to access a preexisting collection with Mongoose?

I have a large collection of 300 question objects in a database test. I can interact with this collection easily through MongoDB's interactive shell; however, when I try to get the collection through Mongoose in an express.js application I get an…
theabraham
  • 15,840
  • 9
  • 42
  • 41
172
votes
8 answers

Why does mongoose always add an s to the end of my collection name

For example, this code results in a collection called "datas" being created var Dataset = mongoose.model('data', dataSchema); And this code results in a collection called "users" being created var User = mongoose.model('user', dataSchema); Thanks
Bob Ren
  • 2,139
  • 2
  • 17
  • 16