urvik
unread,Oct 9, 2010, 6:49:20 AM10/9/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongo-scala-driver
Hi All,
I added few data into Mongo Collection. Three data samples are as
below.
{ "type" : "ABC", "ABC" : [{ "Test" : "Test1 details", "counter" :
1 }, { "Test" : "Test2 details", "counter" : 0 }]}
{ "type" : "XYZ", "XYZ" : [ { "Description" : "Description1 here",
"size" : 70, "counter" : 22 }, { "Description" : "Description2 here",
"size" : 55, "counter" : 10}]}
{ "type" : "XYZ" , "XYZ" : [ { "Description" : "Description3 here" ,
"size" : 36 , "counter" : 13} , { "Description" : "Description4 here",
"size" : 24 , "counter" : 0}]}
I want to find Description and counter values where type = XYZ and
xyz.size is less than 30.I also want to get results sorted by counter
value.
I wrote query db.temp.find({"type" : "XYZ","XYZ.size":{"$lt":30}},
{"XYZ.Description" : 1, "XYZ.counter" : 1})
But got result as below:
{ "_id" : ObjectId("4cb04b621637070000005164"), "XYZ" : [
{
"Description" : "Description3 here",
"counter" : 13
},
{
"Description" : "Description4 here",
"counter" : 0
}
] }
"Description3 here" record should not come as it's size is 36(not less
than 30).
I am new to Mongo. Can some one guide how to resolve this using one
query?
Thanks in advance.
Urvik