AddFields class

$addFields aggregation stage

Stage description.

$addFields appends new fields to existing documents. You can include one or more $addFields stages in an aggregation pipeline.

To add field or fields to embedded documents (including documents in arrays) use the dot notation.

To add an element to an existing array field with $addFields, use with $concatArrays(ConcatArrays).

Example:

Dart code

AddFields({
  'totalHomework': Sum(Field('homework')),
  'totalQuiz': Sum(Field('quiz'))
}).build()

Equivalent mongoDB aggregation stage:

{
 $addFields: {
    totalHomework: { $sum: "$homework" } ,
    totalQuiz: { $sum: "$quiz" }
  }
}

https://docs.mongodb.com/manual/reference/operator/aggregation/addFields/

Inheritance

Constructors

AddFields(Map<String, dynamic> fields)
Creates $addFields aggregation stage

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

build() Map<String, dynamic>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited