2. Query for documents using $lt Query Operator to get all the documents having "name" starting with A,B and C.
> db.people.find({"name":{"$lte":"C"}})
Actual Output:
It did not return the document where name is "Charlie".
Similarly: $gt operator to get all the documents where name starts with Character greater than C, the following query behaves improperly and returns Charlie too. which was not expected.
1. Insert Some Names :
> db.people.insert(
{"name":"Adam"}
)
> db.people.insert(
{"name":"Bob"}
)
> db.people.insert(
{"name":"Charlie"}
)
> db.people.insert(
{"name":"Dwayne"}
)
> db.people.insert(
{"name":"Elika"}
)
2. Query for documents using $lt Query Operator to get all the documents having "name" starting with A,B and C.
> db.people.find({"name":{"$lte":"C"}})
Actual Output:
{ "_id" : ObjectId("5358dfdf8211b04a14804731"), "name" : "Adam" }
{ "_id" : ObjectId("5358dfe38211b04a14804732"), "name" : "Bob" }
Expected Output:
{ "_id" : ObjectId("5358dfdf8211b04a14804731"), "name" : "Adam" }
{ "_id" : ObjectId("5358dfe38211b04a14804732"), "name" : "Bob" }
{ "_id" : ObjectId("5358dfe78211b04a14804733"), "name" : "Charlie" }
It did not return the document where name is "Charlie".
Similarly: $gt operator to get all the documents where name starts with Character greater than C, the following query behaves improperly and returns Charlie too. which was not expected.
Should not return Charlie.
> db.people.find({"name":{"$gt":"C"}})
Actual Output:
{ "_id" : ObjectId("5358dfe78211b04a14804733"), "name" : "Charlie" }
{ "_id" : ObjectId("5358dfef8211b04a14804734"), "name" : "Dwayne" }
{ "_id" : ObjectId("5358dff78211b04a14804735"), "name" : "Elika" }
Expected Output:
{ "_id" : ObjectId("5358dfef8211b04a14804734"), "name" : "Dwayne" }
{ "_id" : ObjectId("5358dff78211b04a14804735"), "name" : "Elika" }
Description
db version v2.4.6
git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673