UnnestStage

public final class UnnestStage extends Stage


Takes a specified array from the input documents and outputs a document for each element with the element stored in a field with name specified by the alias.

Summary

Nested types

public static class UnnestStage.Companion

Public methods

boolean
equals(Object other)
int
static final @NonNull UnnestStage
withField(@NonNull Selectable arrayWithAlias)

Creates UnnestStage with input array and alias specified.

static final @NonNull UnnestStage
withField(@NonNull String arrayField, @NonNull String alias)

Creates UnnestStage with input array and alias specified.

final @NonNull UnnestStage

Adds an index field to the output documents.

Inherited methods

From com.google.firebase.firestore.pipeline.Stage
final @NonNull UnnestStage
final @NonNull UnnestStage
withOption(@NonNull String key, boolean value)

Specify named Boolean parameter

final @NonNull UnnestStage
withOption(@NonNull String key, double value)

Specify named Double parameter

final @NonNull UnnestStage

Specify named Field parameter

final @NonNull UnnestStage
withOption(@NonNull String key, long value)

Specify named Long parameter

final @NonNull UnnestStage

Specify named String parameter

Public methods

equals

public boolean equals(Object other)

hashCode

public int hashCode()

withField

public static final @NonNull UnnestStage withField(@NonNull Selectable arrayWithAlias)

Creates UnnestStage with input array and alias specified.

For each document emitted by the prior stage, this stage will emit zero or more augmented documents. The input array is found in parameter arrayWithAlias, which can be an Expression with an alias specified via Expression.alias, or a Field that can also have alias specified. For each element of the input array, an augmented document will be produced. The element of input array will be stored in a field with name specified by the alias of the arrayWithAlias parameter. If the arrayWithAlias is a Field with no alias, then the original array field will be replaced with the individual element.

Parameters
@NonNull Selectable arrayWithAlias

The input array with field alias to store output element of array.

Returns
@NonNull UnnestStage

UnnestStage with input array and alias specified.

withField

public static final @NonNull UnnestStage withField(@NonNull String arrayField, @NonNull String alias)

Creates UnnestStage with input array and alias specified.

For each document emitted by the prior stage, this stage will emit zero or more augmented documents. The input array found in the previous stage document field specified by the arrayField parameter, will for each element of the input array produce an augmented document. The element of the input array will be stored in a field with name specified by alias parameter on the augmented document.

Returns
@NonNull UnnestStage

UnnestStage with input array and alias specified.

withIndexField

public final @NonNull UnnestStage withIndexField(@NonNull String indexField)

Adds an index field to the output documents.

A field with the name specified in indexField will be added to each output document. The value of this field is a numeric value that corresponds to the array index of the element from the input array.

Parameters
@NonNull String indexField

The name of the index field.

Returns
@NonNull UnnestStage

A new UnnestStage that includes the specified index field.