Project constructor

Project(
  1. Map<String, dynamic> specification
)

Creates $project aggreagtion stage

specification have the following forms:

  • <fieldname>: 1 or true - Specifies the inclusion of a field.
  • <fieldname>: 0 or false - Specifies the exclusion of a field. To exclude a field conditionally, use the Var.remove (REMOVE) variable instead. If you specify the exclusion of a field other than _id, you cannot employ any other $project specification forms. This restriction does not apply to conditionally exclusion of a field using the Var.remove (REMOVE) variable. By default, the _id field is included in the output documents. If you do not need the _id field, you have to exclude it explicitly.
  • <fieldname>: <expression> - Adds a new field or resets the value of an existing field. If the the expression evaluates to Var.remove ($$REMOVE), the field is excluded in the output.

Example:

Dart code:

Project({
  '_id': 0,
  'title': 1,
  'author': 1
}).build()

Equivalent mongoDB aggregation stage:

{ $project : { _id: 0, title : 1 , author : 1 } }

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

Implementation

Project(Map<String, dynamic> specification)
    : super('project', AEObject(specification));