upsert method
Creates or replaces a document from every input.
additionalFields are aliased expressions that are written on top of
the input. collection and documentId are as for insert. See
delete for how write stages behave.
Implementation
Pipeline upsert({
List<Selectable> additionalFields = const <Selectable>[],
Object? collection,
Object? documentId,
Map<String, Object?>? rawOptions,
}) {
final Map<String, Expression> fields = selectablesToMap(
additionalFields,
method: 'upsert',
);
return _append(
Stage(
'upsert',
args: <pb.Value Function(PipelineEncoder)>[
(PipelineEncoder encoder) => encodeExpressionMap(encoder, fields),
],
options: _writeTarget('upsert', collection, documentId),
rawOptions: rawOptions,
),
);
}