Saturday, 31 August 2013

Mongo find - replace ObjectId with attribute of object when find

Mongo find - replace ObjectId with attribute of object when find

Let say I obtain a find result as follows:
{ "_id" : ObjectId("5221517ad1b328371c000003"), "user_id" :
ObjectId("5221517ad1b328371c000001"), "item_id" :
ObjectId("5221517ad1b328371c000002"), "preference" : 22 }
The ObjectId is not quite meaningful. Is there a way to replace the
ObjectId with an object's attribute? eg. for user_id -> change to
username?

No comments:

Post a Comment