Optional
*?: 1 | 0 | booleanawait collection.findOne({}, {
projection: {
_id: 0,
name: 1,
'address.state': 1,
} satisfies StrictProjection<SomeDoc>,
});
await collection.findOne({}, {
projection: {
$vector: 0,
} satisfies StrictProjection<SomeDoc>,
});
await collection.findOne({}, {
projection: {
test_scores: { $slice: [2, 4] },
} satisfies StrictProjection<SomeDoc>,
});
Projection
Specifies which fields should be included/excluded in the returned documents.
Can use
1
/0
, ortrue
/false
.There's a special field
'*'
that can be used to include/exclude all fields.