Q:

Pluck id's from mongo query result

I have the following query on mongo console
db.photos.find({'creation_date': {$gte: <somedate>)}}).

Is there a way to pluck the id's from query result just by using mongo shell ? 

A:

Try using the map() cursor method
var ids = db.photos.find({'creation_date': { '$gte': <somedate>) } }, {'_id': 1})
                   .map(function (doc){ return doc._id; })

You can also use the distinct() method as
var ids = db.photos.distinct('_id', {'creation_date': { '$gte': <somedate>) } })

or with the toArray() cursor method on aggregate() as
var ids = db.photos.aggregate([
    { '$match': {'creation_date': { '$gte': <somedate>) } } }
    { '$group': { '_id': 0, 'ids': { '$push': '$_id' } } }
]).toArray()[0].ids

