i have a collection placements, each record has fields: placement_id, program_id, category, ... i need to find all placements what has program_id = 3 or 5 and only return a
The cursor from find()
is going to yield JSON documents, no matter what.
But you can extract the values you want. Something like this perhaps :
get_placement_id = function(doc) { return doc.placement_id; }
db.placements.find({program_id:{$in: [3, 5]}}, {placement_id:1, _id:0}).map( get_placement_id )
==>
[ 196, 197, 198, ... ]