python - How to use AND condtion in mongokit when a key has multiple values -
i have key in document named "tag". has structure this:
"tag": [ { "schemename": "http:\/\/somesite.com\/categoryscheme2", "name": "test tag2", "value": 1, "slug": "test_tag2" }, { "schemaname": "http:\/\/somesite.com\/categoryscheme3", "name": "test tag3", "value": 1, "slug": "test_tag3" } ],
the values of tag can passed ',' separated. how can use values in , condition saying return enrty having tag = test_tag3&test_tag2
itried : conditions['tag.slug'] = { '$and': tags }
tags
array of tags got :
pymongo.errors.operationfailure operationfailure: database error: invalid operator: $and
use $in
instead of $and
:
conditions['tag.slug'] = { '$in': tags }
Comments
Post a Comment