Skip to main content

One doc tagged with "unwind"

View All Tags

$unwind

The $unwind stage in MongoDB's aggregation pipeline is used to deconstruct an array field from the input documents, generating a new document for each element in the array. Each new document replaces the original document and contains all its fields except for the array, which is replaced by an element from the array. This is particularly useful when you have an array of objects or values and you want to flatten it out for easier processing in subsequent stages.