xxxxxxxxxx
db.collection_name.find({
field_name: {
$gt: ISODate("date"),
$lt: ISODate("date")
}
}
xxxxxxxxxx
-- mongdbo
db.people.find(
{ age: { $gt: 25 } }
)
-- sql
SELECT *
FROM people
WHERE age > 25
-- mongdbo
db.people.find(
{ age: { $lt: 25 } }
)
-- sql
SELECT *
FROM people
WHERE age < 25
-- mongodb
db.people.find(
{ age: { $gt: 25, $lte: 50 } }
)
-- sql
SELECT *
FROM people
WHERE age > 25
AND age <= 50
xxxxxxxxxx
collection.find( { $expr: { $gt: [ "$field1" , "$field2" ] } } )
#field1 greater than field2
xxxxxxxxxx
db.inventory.find( { quantity: { $gt: 20 } } )
Where inventory is collection name
and quantity will be greater than 20