So, I'm trying to use the $ in operator in Pymongo, where I want to search using the MongoID group.
First I have this query to find an array of MongoIDs:
findUsers = db.users.find_one({'_id':user_id},{'_id':0, 'f':1})
If I print findUsers['f'], it looks like this:
[ObjectId('53b2dc0b24c4310292e6def5'), ObjectId('53b6dbb654a7820416a12767')]
These object identifiers are user identifiers, and I want to find all the users in the user collection with this array of ObjectID. So I thought:
foundUsers = db.users.find({'_id':{'$in':findUsers['f']}})
However, when I type foundUsers, the result is as follows:
<pymongo.cursor.Cursor object at 0x10d972c50>
which is not what I usually get when I print a request: (
What am I doing wrong here?
Many thanks.
Also for reference, I requested in the mongo shell and it works as expected:
db.users.find({_id: {$in:[ObjectId('53b2dc0b24c4310292e6def5'), ObjectId('53b6dbb654a7820416a12767')]}})