
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Find value above a specific value in MongoDB documents?
To find values above a specific value, the following is the syntax using $gte in MongoDB −
db.yourCollectionName.find({yourFieldName:{$gte:yourValue}});
Let us create a collection with documents −
> db.demo571.insertOne({"Price":140});{ "acknowledged" : true, "insertedId" : ObjectId("5e909b3439cfeaaf0b97b587") } > db.demo571.insertOne({"Price":100});{ "acknowledged" : true, "insertedId" : ObjectId("5e909b3639cfeaaf0b97b588") } > db.demo571.insertOne({"Price":110});{ "acknowledged" : true, "insertedId" : ObjectId("5e909b3839cfeaaf0b97b589") } > db.demo571.insertOne({"Price":240});{ "acknowledged" : true, "insertedId" : ObjectId("5e909b3c39cfeaaf0b97b58a") }
Display all documents from a collection with the help of find() method −
> db.demo571.find();
This will produce the following output −
{ "_id" : ObjectId("5e909b3439cfeaaf0b97b587"), "Price" : 140 } { "_id" : ObjectId("5e909b3639cfeaaf0b97b588"), "Price" : 100 } { "_id" : ObjectId("5e909b3839cfeaaf0b97b589"), "Price" : 110 } { "_id" : ObjectId("5e909b3c39cfeaaf0b97b58a"), "Price" : 240 }
Following is the query to get values from documents above a specific value −
> db.demo571.find({Price:{$gte:140}});
This will produce the following output −
{ "_id" : ObjectId("5e909b3439cfeaaf0b97b587"), "Price" : 140 } { "_id" : ObjectId("5e909b3c39cfeaaf0b97b58a"), "Price" : 240 }
- Related Articles
- Find MongoDB documents where all objects in array have specific value?
- Find MongoDB documents where elements of an array have a specific value?
- MongoDB aggregation to fetch documents with specific field value?
- Find documents where all elements of an array have a specific value in MongoDB?\n
- Find a value in lowercase from a MongoDB collection with documents
- MongoDB query for documents whose array elements does not have a specific value
- How to get items with a specific value from documents using MongoDB shell?
- MongoDB query to match documents with array values greater than a specific value
- Match MongoDB documents with field value greater than a specific number and fetch them?
- Find documents which contain a particular value in MongoDB using Regular Expressions?
- MongoDB query to fetch a specific document rom documents with field value set using NumberInt()?
- Find documents that contains specific field in MongoDB?
- Find MongoDB documents that contains specific field?
- Find document with array that contains a specific value in MongoDB
- Find MongoDB records with Price less than a specific value

Advertisements