Skip to main content

Unwind

Unpack an array field from the input documents to output a document for each element.

This is extremely useful specially if you're working with a column that have a list of values or when using group stage.

Method Signature

public unwind(column: string, {
includeArrayIndex?: string,
preserveNullAndEmptyArrays?: boolean
}): this;

Example

const users = await aggregate.unwind("hobbies").get();

Read more about unwind.

By default preserveNullAndEmptyArrays is set to false this will trim the result to only documents that have the hobbies field.