define method

Pipeline define(
  1. List<AliasedExpression> variables, {
  2. Map<String, Object?>? rawOptions,
})

Defines variables for the following stages and for subqueries used in them: every aliased expression becomes the variable with that name, read with variable(name).

firestore.pipeline().collection('authors')
    .define([field('name').as('authorName')])
    .addFields([
      firestore.pipeline().collection('books')
          .where(field('author').equal(variable('authorName')))
          .aggregate([countAll().as('count')])
          .toScalarExpression().as('bookCount'),
    ]);

Implementation

Pipeline define(
  List<AliasedExpression> variables, {
  Map<String, Object?>? rawOptions,
}) {
  return _expressionMapStage('let', 'define', variables, rawOptions);
}