Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{name:"A Name",answers:[{order:3},{order:2},{order:1}]}]
Query
db.collection.aggregate([{$unwind:"$answers"},{$addFields:{"answers.id":"$answers.order"}},{$group:{_id:"$_id",answers:{$push:"$answers"}}}])
Result