MongoDB Less than Operation - MongoDB Tutorial




MongoDB Less Than Operation

  • In mongoDB “$lt” selects the documents where the value of the field is less than (i.e. <) the specified value.
  • And the comparison process will be done by only the fields of the documents where as BSON type matches the query value’s type.

Syntax :

{field: {$lt: value} }

Sample Query :

> db.wikitechy4.insert({
... "websitename": "www.wikitechy.com",
... "details":"row to check less than",
... "articlepoints":10,
... "author":"jln"
... })

WriteResult({ "nInserted" : 1 })

> db.wikitechy4.insert({
... "websitename": "www.wikitechy.com",
... "details":"row to check less than",
... "articlepoints":50,
... "author":"arun"
... })

WriteResult({ "nInserted" : 1 })

> db.wikitechy4.find(
               {"articlepoints":{$lt:20}}
            ).pretty()

{
        "_id" : ObjectId("5731ff77daa4a0bc932a3000"),
        "websitename" : "www.wikitechy.com",
        "details" : "row to check less than",
        "articlepoints" : 10,
        "author" : "jln"
}
>

MongoDb


Output

MongoDb
  1. Here in this statement, the data’s “websitename”:www.wikitechy.com” , ”details”:”row to check less than”,”articlepoints”:”10” and the “author “ : “jln” are being inserted into the collection ”wikitechy4”.
  2. Here this statement, we add another row of data’s “websitename”:www.wikitechy.com” ,”details”:”row to check less than”,”articlepoints”:”50” and the “author “ : “arun” are being inserted into the collection ”wikitechy4”.
  3. In this statement we perform a lesser than operation where the “articlepoint:” value must be lesser than “20” , thereby it displays the data’s “websitename”:www.wikitechy.com” , ”details”:”row to check less than”,”articlepoints”:”10” and the “author “ : “jln”


Related Searches to MongoDB Less than Operation - MongoDB Tutorial

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×