How do I check if list1 contains A and list2 开发者_如何学Pythondon't contains A? both list1 and list2 are array (list2 can be empty or not set)
I tried query:
{
'list1':'A',
'list2':{ '$ne':'A'}
}
but I'm getting results with list1 contains A and list2 contains A.
if I remove 'list2':{ '$ne':'A'} ...
results is the same, likes list2 part don't metter
strange ...am I doing something wrong?
I was updating it wrong. Should be this:
db.test.update({ _id: X }, {'$push': {"a2": 'A'}});
Or this:
db.test.update({ _id: X }, {'$set': {"a2": ['A']}});
the document looks like this:
{ "_id" : ObjectId("4dbacb40696b6ede04c5ef97"), "a1" : [ "A" ], "a2" :
{ "0" : "A" } }
Where it's correct that {"0": "A"}
is not equal to A
精彩评论