The condition operators in MongoDB are:
· (>) Greater than-$GT
· (<) less than-$lt
· (>=) greater than or equal to-$gte
· (<=) less than or equal to-$lte
We used the database name "Runoob", our collection name is "Col", the following is the data we inserted.
To facilitate testing, we can use the following command to empty the collection "col" Data:
Db.col.remove ({})
Insert the following data:
>db.col.insert ({
title: ' PHP Tutorial ',
Description: ' PHP is a powerful server-side scripting language for creating dynamic interactive sites. ' By
: ' Rookie tutorial ',
URL: ' http://www.runoob.com ',
Tags: [' php '],
likes:200
})
>db.col.insert ({title: ' Java Tutorial ',
Description: ' Java is a high-level programming language introduced by Sun Microsystems Company in May 1995. ' By
: ' Rookie tutorial ',
URL: ' http://www.runoob.com ',
Tags: [' java '],
likes:150
})
>db.col.insert ({title: ' MongoDB Tutorial ',
Description: ' MongoDB is a Nosql database ' by
: ' Rookie tutorial ',
URL: '/http '/ Www.runoob.com ',
Tags: [' MongoDB '],
likes:100
})
Use the Find () command to view the data:
> Db.col.find ()
{"_id": ObjectId ("56066542ade2f21f36b0313a"), "title": "PHP Tutorial", "description": "PHP is a kind of creating dynamic interactivity A powerful server-side scripting language for the site. "By": "Rookie Tutorial", "url": "Http://www.runoob.com", "tags": ["PHP"], "likes": $
{"_id": ObjectId ("56066549ade 2f21f36b0313b ")," title ":" Java Tutorial "," description ":" Java is a high-level programming language introduced by Sun Microsystems Company in May 1995. "By": "Rookie Tutorial", "url": "Http://www.runoob.com", "tags": ["Java"], "likes": [] {"
_id": ObjectId ("5606654fad e2f21f36b0313c ")," title ":" MongoDB Tutorial "," description ":" MongoDB is a Nosql database "," by ":" Rookie Tutorial "," url ":" Http://www.runo Ob.com "," tags ": [" MongoDB "]," likes ": 100}
MongoDB (>) greater than operator-$GT
db.col.find ({"likes": {$gt: 100}})//Get "col" collection