collect funtion to return nested element as an array

Collect function like rails. 
Will be useful in cases where you just want to get a particular field from all the records and use them in a whereIn query. Right now we have to iterate over each record even if just want to get a single field and then call a whereIn query to some other model.