literals method

Pipeline literals(
  1. List<Map<String, Object?>> documents, {
  2. Map<String, Object?>? rawOptions,
})

Uses the given maps as the input, without reading the database. Values may be Expressions, also inside nested maps and lists.

Implementation

Pipeline literals(
  List<Map<String, Object?>> documents, {
  Map<String, Object?>? rawOptions,
}) {
  for (final Map<String, Object?> document in documents) {
    _validateLiteral(
      document,
      UserDataParseAccumulator(UserDataSource.argument).rootContext,
    );
  }
  final List<Map<String, Expression>> encoded = documents
      .map(
        (Map<String, Object?> document) => <String, Expression>{
          for (final MapEntry<String, Object?> entry in document.entries)
            entry.key: toExpression(entry.value),
        },
      )
      .toList(growable: false);
  return _start(
    Stage(
      'literals',
      args: <pb.Value Function(PipelineEncoder)>[
        for (final Map<String, Expression> document in encoded)
          (PipelineEncoder encoder) => encodeExpressionMap(encoder, document),
      ],
      rawOptions: rawOptions,
    ),
  );
}