Tsallaka zuwa abun ciki
Justice Tech School

$unwind

Flatten arrays into documents.

Example
db.posts.aggregate([
  { $unwind: "$tags" },
  { $group: { _id: "$tags", n: { $sum: 1 } } }
])

Exercise

Flatten.

{ : "$tags" }

Quiz Test

What does $unwind do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.