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
278
votes
22 answers

Avoid "current URL string parser is deprecated" warning by setting useNewUrlParser to true

I have a database wrapper class that establishes a connection to some MongoDB instance: async connect(connectionString: string): Promise { this.client = await MongoClient.connect(connectionString) this.db =…
Lion
  • 16,606
  • 23
  • 86
  • 148
277
votes
19 answers

How do I partially update an object in MongoDB so the new object will overlay / merge with the existing one

Given this document saved in MongoDB { _id : ..., some_key: { param1 : "val1", param2 : "val2", param3 : "val3" } } An object with new information on param2 and param3 from the outside world needs to be saved var…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
275
votes
4 answers

MongoDB inserts float when trying to insert integer

> db.data.update({'name': 'zero'}, {'$set': {'value': 0}}) > db.data.findOne({'name': 'zero}) {'name': 'zero', 'value': 0.0} How do I get Mongo to insert an integer? Thank you
daydreamer
  • 87,243
  • 191
  • 450
  • 722
259
votes
7 answers

MongoDB Show all contents from all collections

Is it possible to show all collections and its contents in MongoDB? Is the only way to show one by one?
Reno
  • 2,639
  • 2
  • 12
  • 7
258
votes
4 answers

MongoDB: update every document on one field

I have a collected named foo hypothetically. Each instance of foo has a field called lastLookedAt which is a UNIX timestamp since epoch. I'd like to be able to go through the MongoDB client and set that timestamp for all existing documents (about…
randombits
  • 47,058
  • 76
  • 251
  • 433
252
votes
11 answers

Difference between MongoDB and Mongoose

I wanted to use the mongodb database, but I noticed that there are two different databases with either their own website and installation methods: mongodb and mongoose. So I came up asking myself this question: "Which one do I use?". So in order to…
Ravindra Galav
  • 2,730
  • 2
  • 13
  • 16
251
votes
10 answers

What did MongoDB not being ACID compliant before v4 really mean?

I am not a database expert and have no formal computer science background, so bear with me. I want to know the kinds of real world negative things that can happen if you use an old MongoDB version prior to v4, which were not ACID compliant. This…
Lance
  • 75,200
  • 93
  • 289
  • 503
250
votes
11 answers

Node.js Mongoose.js string to ObjectId function

Is there a function to turn a string into an objectId in node using mongoose? The schema specifies that something is an ObjectId, but when it is saved from a string, mongo tells me it is still just a string. The _id of the object, for instance, is…
JRPete
  • 3,074
  • 3
  • 19
  • 17
250
votes
22 answers

add created_at and updated_at fields to mongoose schemas

Is there a way to add created_at and updated_at fields to a mongoose schema, without having to pass them in everytime new MyModel() is called? The created_at field would be a date and only added when a document is created. The updated_at field would…
chovy
  • 72,281
  • 52
  • 227
  • 295
247
votes
16 answers

How to Update Multiple Array Elements in mongodb

I have a Mongo document which holds an array of elements. I'd like to reset the .handled attribute of all objects in the array where .profile = XX. The document is in the following form: { "_id": ObjectId("4d2d8deff4e6c1d71fc29a07"), …
LiorH
  • 18,524
  • 17
  • 70
  • 98
241
votes
4 answers

How do you update objects in a document's array (nested updating)

Assume we have the following collection, which I have few questions about: { "_id" : ObjectId("4faaba123412d654fe83hg876"), "user_id" : 123456, "total" : 100, "items" : [ { "item_name" :…
Majid
  • 2,845
  • 3
  • 15
  • 14
239
votes
11 answers

Date query with ISODate in mongodb doesn't seem to work

I don't seem to be able to get even the most basic date query to work in MongoDB. With a document that looks something like this: { "_id" : "foobar/201310", "ap" : "foobar", "dt" : ISODate("2013-10-01T00:00:00.000Z"), "tl" :…
Jason Polites
  • 5,571
  • 3
  • 25
  • 24
233
votes
21 answers

How to sort in mongoose?

I find no documentation for the sort modifier. The only insight is in the unit tests: spec.lib.query.js#L12 writer.limit(5).sort(['test', 1]).group('name') But it doesn't work for me: Post.find().sort(['updatedAt', 1]);
Philippe Rathé
  • 8,888
  • 3
  • 22
  • 13
232
votes
20 answers

How do I create a MongoDB dump of my database?

What command should I use to create a MongoDB dump of my database?
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
228
votes
10 answers

Find duplicate records in MongoDB

How would I find duplicate fields in a mongo collection. I'd like to check if any of the "name" fields are duplicates. { "name" : "ksqn291", "__v" : 0, "_id" : ObjectId("540f346c3e7fc1054ffa7086"), "channel" : "Sales" } Many thanks!
Chris
  • 3,004
  • 3
  • 21
  • 26