node.js - Mongoose populate data key remove in got data -
i'm using relation between 2 collection , have collection schema follow.
// room database entry. { "_id" : objectid("59b77082f7da4b1b3f64d927"), "room_id" : "c3wqqkfndg9cnmi", "room_name" : "bcmvnxbcnvsjkfhkjdh", "users" : [ { "_id" : objectid("59b77082f7da4b1b3f64d926") } ], "__v" : 0 } //user database entry, related above room entry. { "_id" : objectid("59b77082f7da4b1b3f64d926"), "user_id" : "dyr1qlrtso47vi", "__v" : 0 }
when pass query room find , populate data found result follow.
// query room find , populate. room .findone({ room_id: result.data.room_id }) .populate("users._id") .exec(function(err, data){ }); //result follow { "_id":"59b77082f7da4b1b3f64d927", "room_id":"c3wqqkfndg9cnmi", "room_name":"bcmvnxbcnvsjkfhkjdh", "__v":0, "users":[ { "_id":{ "_id":"59b77082f7da4b1b3f64d926", "user_id":"dyr1qlrtso47vi", "__v":0 } } ] }
my requirement follow, don't want _id
key of object. need users
object follow.
"users":[ { "_id":{ "_id":"59b77082f7da4b1b3f64d926", "user_id":"dyr1qlrtso47vi", "__v":0 } } ] should "users":[ { "_id":"59b77082f7da4b1b3f64d926", "user_id":"dyr1qlrtso47vi", "__v":0 } ]
Comments
Post a Comment