$and with $not, how do I write a query in morphia

30 views
Skip to first unread message

cgrchen

unread,
Aug 22, 2012, 8:51:14 PM8/22/12
to mor...@googlegroups.com
Hello,

I have this sample entry:
{
  "_id" : ObjectId("5035648bc2ce90bf9272d022"),
  "testMap" : {
    "a" : {
      "testArray" : [1, 1, 2, 2, 3, 4]
    },
    "b" : {
      "testArray" : [1, 2, 3, 4, 5, 6]
    }
  }
}

So my goal is to find a particular number in a particular node, but it can't have the complete 6 numbers. For example, this should return the record above:
db.testColl.findOne(
{$and:
[
{"testMap.a.testArray":1},
{"testMap.a.testArray":{$not:{$all:[1,2,3,4,5,6]}}}
]}
);

However, this should return nothing:
db.testColl.findOne(
{$and:
[
{"testMap.b.testArray":1},
{"testMap.b.testArray":{$not:{$all:[1,2,3,4,5,6]}}}
]}
);

Can someone help me with this? If not, how do I manually write this query, but parse the result to an object?

Thanks,
Rick
Reply all
Reply to author
Forward
0 new messages