I have an abccollection collection whose documents look like:
{
id:123
focusPoint:89652.33
}
I want to retrieve all focusPoint values so that output looks like:
[89652.33, 89999.223, 99666.45, ...]
If you want to get a list without duplicates:
db.abccollection.distinct("focusPoint")
Otherwise, keeping duplicates:
db.abccollection.find({}, { _id: 0, focusPoint: 1 }).map((doc) => doc.focusPoint)
With that you will retrieve all the documents in the abccollection collection and project just the focusPoint field. The raw output of that query (before the map) will be an array of documents with a single field:
[{ focusPoint: 89652.33 }, { focusPoint: 89999.223 }, ...]
If you don't want MongoDB to do the .map in MongoDB, you can also do it in your application.