Database

[{_id:ObjectId("623e2f0cb242ee9367eb3c9f"),subjects:[{id:"1",name:"math"},{id:"2",name:"physics"}]},{_id:ObjectId("623e2f17b242ee9367eb3ca0"),subjects:[{id:"1",name:"math"},{id:"3",name:"biology"}]}]

Query

db.collection.aggregate([{"$project":{"_id":0,"newSubjects":{"$arrayToObject":{"$map":{"input":"$$ROOT.subjects","in":{"k":"$$this.id","v":{"id":"$$this.id","name":"$$this.name"}}}}}}}])

Result