Quering a document using an instance of ObjectId does not return a result even if the document exists.
Try this in python console:
import pymongo
from bson import ObjectId
client = pymongo.MongoClient('localhost', 27017)
db = client.local
db.test.insert(
{"_id": "51c9d99649b5d534db8d483a", "var": "foo"})
try:
doc = db.test.find_one(
)
assert (doc != None)
except:
print 'Document not found!'
try:
doc = db.test.find_one(
)
assert (doc != None)
except:
print 'Document not found!'
Using the string representation of ObjectId returns the spected result.