motine / Ohouse

Ohouse
Other
3 stars 2 forks source link

Several URNs For Matching During Slice LookUp #25

Closed zanetworker closed 10 years ago

zanetworker commented 10 years ago

In the current Ohouse implementation, only lookup with one matching URN is supported; however, in the specification several URNs are supported during lookup.

motine commented 10 years ago
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/