Project constructor
Creates $project
aggreagtion stage
specification
have the following forms:
<fieldname>
:1
ortrue
- Specifies the inclusion of a field.<fieldname>
:0
orfalse
- 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));