mongodbMongoDB query example
MongoDB is a document-oriented NoSQL database used for high volume data storage. It is an open-source database that uses a document-oriented data model, which means data is stored in JSON-like documents with dynamic schemas.
Below is an example of a MongoDB query that finds all documents in the collection "users" where the "age" field is greater than or equal to 18:
db.users.find({ age: { $gte: 18 } })
The output of this query would be a list of documents in the "users" collection where the "age" field is greater than or equal to 18.
Code explanation
db.users
: This is the collection that the query is searching in.find()
: This is the method used to search the collection.{ age: { $gte: 18 } }
: This is the query condition, which specifies that the documents returned must have an "age" field greater than or equal to 18.
Helpful links
More of Mongodb
- How to check the version of MongoDB?
- How to use watch in MongoDB?
- How to use unwind in MongoDB?
- How to insert new document into MongoDB?
- How to perform a health check for MongoDB?
- How to use triggers in MongoDB?
- How to work with time series data in MongoDB?
- How to list MongoDB users?
- How to update an array element in MongoDB?
- How to update many documents in MongoDB?
See more codes...