#include <userver/storages/mongo/options.hpp>
Selects fields to be returned.
_id
field is always included by default, order might be significant Definition at line 158 of file options.hpp.
Public Member Functions | |
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. | |
Projection & storages::mongo::options::Projection::ElemMatch | ( | std::string_view | field, |
const formats::bson::Document & | pred ) |
Matches the first element of an array satisfying a predicate.
field | name of the array to search |
pred | predicate to apply to elements |
Projection & storages::mongo::options::Projection::Exclude | ( | std::string_view | field | ) |
Excludes a field from the projection.
_id
field can always be excluded. Projection & storages::mongo::options::Projection::Slice | ( | std::string_view | field, |
int32_t | limit, | ||
int32_t | skip = 0 ) |
Setups an array slice in the projection.
field | name of the array field to slice |
limit | the number of items to return |
skip | the following number of items |
skip
can be negative, this corresponds to counting from the end backwards. limit < 0, skip == 0
is equivalent to ‘limit’ = -limit, skip' = limit`.