Mangrove
The C++ Object Document Mapper for MongoDB
Public Member Functions | List of all members
mangrove::push_update_expr< NvpT, U, Sort > Class Template Reference

Represents an array update epression that uses the $push operator. More...

#include <query_builder.hpp>

Public Member Functions

constexpr push_update_expr (const NvpT &nvp, const U &val, bool each, bsoncxx::stdx::optional< std::int32_t > slice=bsoncxx::stdx::nullopt, const bsoncxx::stdx::optional< Sort > &sort=bsoncxx::stdx::nullopt, bsoncxx::stdx::optional< std::uint32_t > position=bsoncxx::stdx::nullopt)
 Constructs a $push expression, with the given optional modifiers. More...
 
constexpr push_update_expr< NvpT, U, Sort > slice (std::int32_t slice)
 Create a copy of this expression with a different $slice modifier value. More...
 
constexpr push_update_expr< NvpT, U, Sort > slice ()
 Create a copy of this expression without a $slice modifier. More...
 
template<typename OtherNvpT >
constexpr push_update_expr< NvpT, U, sort_expr< OtherNvpT > > sort (const sort_expr< OtherNvpT > &sort)
 Create a copy of this expression with a different $sort modifier value. More...
 
constexpr push_update_expr< NvpT, U, int > sort (int sort)
 Create a copy of this expression with a different $slice modifier value. More...
 
constexpr push_update_expr< NvpT, U, Sort > sort ()
 Create a copy of this expression without a $sort modifier. More...
 
constexpr push_update_expr< NvpT, U, Sort > position (std::uint32_t position)
 Create a copy of this expression with a different $position modifier value. More...
 
constexpr push_update_expr< NvpT, U, Sort > position ()
 Create a copy of this expression without $position modifier. More...
 
void append_to_bson (bsoncxx::builder::core &builder, bool wrap=false) const
 Appends this query to a BSON core builder as an expression '. More...
 

Detailed Description

template<typename NvpT, typename U, typename Sort>
class mangrove::push_update_expr< NvpT, U, Sort >

Represents an array update epression that uses the $push operator.

Modifiers can be set either in the constructor, or by calling the corresponding member functions.

Template Parameters
NvpTThe name-value-pair type of the corresponding field.
UThe value being $push'ed to the array
SortThe type of the sort expression used in the $sort modifier. This can be either an integer, +/- 1, or a sort_expr.

Constructor & Destructor Documentation

template<typename NvpT , typename U , typename Sort >
constexpr mangrove::push_update_expr< NvpT, U, Sort >::push_update_expr ( const NvpT &  nvp,
const U &  val,
bool  each,
bsoncxx::stdx::optional< std::int32_t >  slice = bsoncxx::stdx::nullopt,
const bsoncxx::stdx::optional< Sort > &  sort = bsoncxx::stdx::nullopt,
bsoncxx::stdx::optional< std::uint32_t >  position = bsoncxx::stdx::nullopt 
)
inline

Constructs a $push expression, with the given optional modifiers.

Parameters
nvpThe field to modify
valThe value to append to the field
eachWhether to append a single value, or a bunch of values in an array.
sliceAn optional value to give the $slice modifier. This only takes effect with each=true.
sortAn optional value to give the $sort modifier. This only takes effect with each=true.
positionAn optional value to give the $position modifier. This only takes effect with each=true.

Member Function Documentation

template<typename NvpT , typename U , typename Sort >
void mangrove::push_update_expr< NvpT, U, Sort >::append_to_bson ( bsoncxx::builder::core &  builder,
bool  wrap = false 
) const
inline

Appends this query to a BSON core builder as an expression '.

push
{field: value | {

each: value, $modifiers: params...}}'

Parameters
builderA basic BSON core builder.
Whetherto wrap this expression inside a document.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, Sort> mangrove::push_update_expr< NvpT, U, Sort >::position ( std::uint32_t  position)
inline

Create a copy of this expression with a different $position modifier value.

Parameters
positionThe integer value of the $position modifier.
Returns
A new push_update_expr with the same properties as this one, except a different $position modifier.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, Sort> mangrove::push_update_expr< NvpT, U, Sort >::position ( )
inline

Create a copy of this expression without $position modifier.

Returns
A new push_update_expr with the same properties as this one, except a different $position modifier.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, Sort> mangrove::push_update_expr< NvpT, U, Sort >::slice ( std::int32_t  slice)
inline

Create a copy of this expression with a different $slice modifier value.

Parameters
sliceThe integer value of the $slice modifier.
Returns
A new push_update_expr with the same properties as this one, except a different $slice modifier.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, Sort> mangrove::push_update_expr< NvpT, U, Sort >::slice ( )
inline

Create a copy of this expression without a $slice modifier.

Returns
A new push_update_expr with the same properties as this one, except a different $slice modifier.
template<typename NvpT , typename U , typename Sort >
template<typename OtherNvpT >
constexpr push_update_expr<NvpT, U, sort_expr<OtherNvpT> > mangrove::push_update_expr< NvpT, U, Sort >::sort ( const sort_expr< OtherNvpT > &  sort)
inline

Create a copy of this expression with a different $sort modifier value.

Template Parameters
OtherNvpTThe name-value-pair used by the given Sort Expression.
Parameters
sortThe sort expression to use.
Returns
A new push_update_expr with the same properties as this one, except a different $sort modifier.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, int> mangrove::push_update_expr< NvpT, U, Sort >::sort ( int  sort)
inline

Create a copy of this expression with a different $slice modifier value.

Parameters
sortThe integer value of the $sort modifier, +/-1.
Returns
A new push_update_expr with the same properties as this one, except a different $sort modifier.
template<typename NvpT , typename U , typename Sort >
constexpr push_update_expr<NvpT, U, Sort> mangrove::push_update_expr< NvpT, U, Sort >::sort ( )
inline

Create a copy of this expression without a $sort modifier.

Returns
A new push_update_expr with the same properties as this one, except a different $sort modifier.

The documentation for this class was generated from the following files: