Closed zanetworker closed 10 years ago
lookup_slice
return multiple records if there is a list specified.import pymongo
def print_contents(cursor):
print "\n".join([str(x) for x in cursor])
client = pymongo.MongoClient()
db = client['testdb']
collection = db['col']
# # insert test data
# collection.insert({"a" : 1, "b" : 10})
# collection.insert({"a" : 2, "b" : 20})
# collection.insert({"a" : 3, "b" : 30})
# collection.insert({"a" : 4, "b" : 40})
print "retrieve one:"
print_contents(collection.find({"a": 2}))
print "retrieve multiple (or, naive, defunc):"
print_contents(collection.find({"a": [1,2]}))
print "retrieve two (working):"
print_contents(collection.find({"a": {"$in" :[1,2]}})) # see http://docs.mongodb.org/manual/reference/operator/query/
In the current Ohouse implementation, only lookup with one matching URN is supported; however, in the specification several URNs are supported during lookup.