Selects fields to be returned.
More...
#include <userver/storages/mongo/options.hpp>
|
| Projection ()=default |
| Creates a default projection including all fields.
|
|
| Projection (std::initializer_list< std::string_view > fields_to_include) |
| Creates a projection including only specified fields.
|
|
Projection & | Include (std::string_view field) |
| Includes a field into the projection.
|
|
Projection & | Exclude (std::string_view field) |
| Excludes a field from the projection.
|
|
Projection & | Slice (std::string_view field, int32_t limit, int32_t skip=0) |
| Setups an array slice in the projection.
|
|
Projection & | ElemMatch (std::string_view field, const formats::bson::Document &pred) |
| Matches the first element of an array satisfying a predicate.
|
|
Selects fields to be returned.
- Note
_id
field is always included by default, order might be significant
- See also
- https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/
Definition at line 158 of file options.hpp.
◆ ElemMatch()
Matches the first element of an array satisfying a predicate.
- Parameters
-
field | name of the array to search |
pred | predicate to apply to elements |
- Note
- Array field will be absent from the result if no elements match.
-
Empty document as a predicate will only match empty documents.
◆ Exclude()
Projection & storages::mongo::options::Projection::Exclude |
( |
std::string_view |
field | ) |
|
Excludes a field from the projection.
- Warning
- Projection cannot have a mix of inclusion and exclusion. Only the
_id
field can always be excluded.
◆ Slice()
Projection & storages::mongo::options::Projection::Slice |
( |
std::string_view |
field, |
|
|
int32_t |
limit, |
|
|
int32_t |
skip = 0 |
|
) |
| |
Setups an array slice in the projection.
- Parameters
-
field | name of the array field to slice |
limit | the number of items to return |
skip | the following number of items |
- Note
skip
can be negative, this corresponds to counting from the end backwards.
-
limit < 0, skip == 0
is equivalent to ‘limit’ = -limit, skip' = limit`.
- Warning
- Cannot be applied to views.
The documentation for this class was generated from the following file: