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
328
votes
9 answers

return query based on date

I have a data like this in mongodb { "latitude" : "", "longitude" : "", "course" : "", "battery" : "0", "imei" : "0", "altitude" : "F:3.82V", "mcc" : "07", "mnc" : "007B", "lac" : "2A83", "_id" :…
coure2011
  • 40,286
  • 83
  • 216
  • 349
328
votes
8 answers

How to list all databases in the mongo shell?

I know how to list all collections in a particular database, but how do I list all available databases in MongoDB shell?
fracz
  • 20,536
  • 18
  • 103
  • 149
325
votes
12 answers

Push items into mongo array via mongoose

Basically I have a mongodb collection called 'people' whose schema is as follows: people: { name: String, friends: [{firstName: String, lastName: String}] } Now, I have a very basic express application that connects to…
Neurax
  • 3,657
  • 2
  • 13
  • 18
324
votes
7 answers

Stop Mongoose from creating _id property for sub-document array items

If you have subdocument arrays, Mongoose automatically creates ids for each one. Example: { _id: "mainId" subDocArray: [ { _id: "unwantedId", field: "value" }, { _id: "unwantedId", field:…
Atlas
  • 3,343
  • 2
  • 13
  • 9
320
votes
17 answers

MongoDB - admin user not authorized

I am trying to add authorization to my MongoDB. I am doing all this on Linux with MongoDB 2.6.1. My mongod.conf file is in the old compatibility format (this is how it came with the installation). 1) I created admin user as described here in…
peter.petrov
  • 38,363
  • 16
  • 94
  • 159
319
votes
36 answers

How to paginate with Mongoose in Node.js?

I am writing a webapp with Node.js and mongoose. How can I paginate the results I get from a .find() call? I would like a functionality comparable to "LIMIT 50,100" in SQL.
Thomas
  • 10,289
  • 13
  • 39
  • 55
318
votes
31 answers

Render basic HTML view?

I have a basic Node.js app that I am trying to get off the ground using the Express framework. I have a views folder where I have an index.html file. But I receive the following error when loading the web page: Error: Cannot find module…
aherrick
  • 19,799
  • 33
  • 112
  • 188
316
votes
9 answers

How to print out more than 20 items (documents) in MongoDB's shell?

db.foo.find().limit(300) won't do it. It still prints out only 20 documents. db.foo.find().toArray() db.foo.find().forEach(printjson) will both print out very expanded view of each document instead of the 1-line version for find():
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
309
votes
11 answers

MongoDB: Combine data from multiple collections into one..how?

How can I (in MongoDB) combine data from multiple collections into one collection? Can I use map-reduce and if so then how? I would greatly appreciate some example as I am a novice.
user697697
  • 3,327
  • 3
  • 18
  • 12
305
votes
9 answers

Comparing mongoose _id and strings

I have a node.js application that pulls some data and sticks it into an object, like this: var results = new Object(); User.findOne(query, function(err, u) { results.userId = u._id; } When I do an if/then based on that stored ID, the…
pat
  • 3,513
  • 3
  • 17
  • 20
298
votes
25 answers

How to copy a collection from one database to another in MongoDB

Is there a simple way to do this?
EasonBlack
  • 4,196
  • 4
  • 21
  • 24
296
votes
7 answers

How can I rename a field for all documents in MongoDB?

Assuming I have a collection in MongoDB with 5000 records, each containing something similar to: { "occupation":"Doctor", "name": { "first":"Jimmy", "additional":"Smith" } Is there an easy way to rename the field "additional" to "last" in all…
soulkphp
  • 3,753
  • 2
  • 17
  • 14
294
votes
4 answers

How to query nested objects?

I have a problem when querying mongoDB with nested objects notation: db.messages.find( { headers : { From: "reservations@marriott.com" } } ).count() 0 db.messages.find( { 'headers.From': "reservations@marriott.com" } ).count() 5 I can't see what I…
Edmondo
  • 19,559
  • 13
  • 62
  • 115
284
votes
10 answers

NoSQL (MongoDB) vs Lucene (or Solr) as your database

With the NoSQL movement growing based on document-based databases, I've looked at MongoDB lately. I have noticed a striking similarity with how to treat items as "Documents", just like Lucene does (and users of Solr). So, the question: Why would…
eduncan911
  • 17,165
  • 13
  • 68
  • 104
280
votes
6 answers

What are naming conventions for MongoDB?

Is there a set of preferred naming conventions for MongoDB entitites such as databases, collections, field names? I was thinking along these lines: Databases: consist of the purpose (word in singular) and end with “db” – all lower case: imagedb,…
Andrey
  • 20,487
  • 26
  • 108
  • 176