$unwind
Flatten arrays into documents.
Example
db.posts.aggregate([
{ $unwind: "$tags" },
{ $group: { _id: "$tags", n: { $sum: 1 } } }
])Exercise
Flatten.
{ : "$tags" }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.