I am playing around with monogdb for an assignment, and I have ran into the following issue: the document returned by pymongo doesn't match what is returned by mongoc. A simple test.py:
from pymongo import MongoClient
from bson.objectid import ObjectId
client = MongoClient()
db = client['dev_database']
print db.trials.find_one(ObjectId('522f975dc91e273451569942'))
print list(db.trials.find({'_id':ObjectId('522f975dc91e273451569942')}))
Doing it both ways just in case. This returns:
{u'nurse_id': u'522f975dc91e273451569941', u'question_ids': [], u'name': u'Test Trial', u'clinician_id': u'522f975dc91e273451569940', u'arms': {u'Med1': u'', u'Placebo': u''}, u'participant_ids': [], u'keywords': [u'abc', u'123'], u'_id': ObjectId('522f975dc91e273451569942')}
[{u'nurse_id': u'522f975dc91e273451569941', u'question_ids': [], u'name': u'Test Trial', u'clinician_id': u'522f975dc91e273451569940', u'arms': {u'Med1': u'', u'Placebo': u''}, u'participant_ids': [], u'keywords': [u'abc', u'123'], u'_id': ObjectId('522f975dc91e273451569942')}]
And if I do the same thing inside MongoDB Shell:
> use dev_database
switched to db dev_database
> db.trials.find('522f975dc91e273451569942')
{ "_id" : "522f975dc91e273451569942", "nurse_id" : "522f975dc91e273451569941", "question_ids" : [ ], "name" : "Test Trial", "clinician_id" : "522f975dc91e273451569940", "arms" : { "Med1" : "", "Placebo" : "" }, "participant_ids" : [
"52325b93c91e274e81f4bdda",
"52325b93c91e274e81f4bddb",
"52325b93c91e274e81f4bddc",
"52325b93c91e274e81f4bddd",
"52325b93c91e274e81f4bdde"
], "keywords" : [ "abc", "123" ] }
>
As you can see, test.py returns a document where participant_ids is an empty list, but MongoDB Shell says otherwise.
I have no idea why this is, and it seems like I must be make a simple, but fundamental mistake somewhere.