Database
db={"association":[{"id":1,"parentId":1,"position":{"x":1,"y":1},"tag":"Beta"},{"id":2,"parentId":2,"position":{"x":2,"y":2},"tag":"Alpha"},{"id":3,"parentId":1,"position":{"x":3,"y":3},"tag":"Delta"},{"id":4,"parentId":1,"position":{"x":4,"y":4},"tag":"Gamma"},{"id":5,"parentId":2,"position":{"x":5,"y":6},"tag":"Epsilon"}]}
Query
db.association.aggregate([{$sort:{parentId:1,id:1}},{$group:{_id:"$parentId",children:{$push:{position:"$position",tag:"$tag"}}}},{$replaceRoot:{newRoot:{$mergeObjects:["$$ROOT",{$arrayElemAt:["$children",0]}]}}},{$addFields:{children:{$slice:["$children",1,{$size:"$children"}]}}}])