$unwind "bung" một mảng trong document ra thành nhiều document riêng, mỗi document ứng với một phần tử của mảng. Thường dùng trước $group hay $lookup để xử lý từng phần tử riêng lẻ.
Ví dụ: một post có tags: ["A", "B"], sau $unwind sẽ thành 2 document — một cái tags: "A", một cái tags: "B". Sau đó có thể $group để đếm số post theo từng tag chẳng hạn.
$unwind "explodes" an array in a document into several documents, one per array element. It is typically used before $group or $lookup to process each element individually.
Example: a post with tags: ["A", "B"] becomes 2 documents after $unwind — one with tags: "A" and one with tags: "B". You can then $group to, say, count posts per tag.