To get an array of every _id into you object you can use a $map.
Map is similar as JS map, check this:
const array = [
{"id": 1,"other": ""},
{"id": 2,"other": ""},
{"id": 3,"other": ""},
{"id": 4,"other": ""},
{"id": 5,"other": ""}]
console.log(array.map(m => m.id))
You can get this approach using mongo $map into a $project stage like this:
With this aggregation you are creating a field called array where using $map return array.id, so it creates an array of desired ids.
db.collection.aggregate([
{
"$project": {
"_id": 0,
"array": {
"$map": {
"input": "$array",
"as": "a",
"in": "$$a.id"
}
}
}
}
])
Example here
$projectand$map: example. Is this example correct for you?