✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
Alice wants to create two collections in MongoDB called the unitEnrolment collection andthe student collection. The relationship between the two collections is one-to-many. Onedocument in the unitEnrolment collection has many related documents in the student collection.
She wrote the following two MongoDB shell commands to populate the database:
db.unitEnrolment.insertOne({"_id":1, "code":"FIT5148", "students":[1,2,3,4,5]})
db.student.insertMany([{"_id":1,"name":"Alita"},{"_id":4,"name":"Nick"},{"_id":5,"name":"Tom"}])
Alice’s aggregation pipeline code produces the following output:
{"_id" : 1, "students" : 1, "details" : [{ "_id" : 1, "name" : "Alita" }]}
{"_id" : 1, "students" : 2, "details" : [ ] }
{"_id" : 1, "students" : 3, "details" : [ ] }
{"_id" : 1, "students" : 4, "details" : [ { "_id" : 4, "name" : "Nick" } ] }
{"_id" : 1, "students" : 5, "details" : [ { "_id" : 5, "name" : "Tom" } ] }
Which of the following aggregation query will produce the above output?