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

A CRTP base class that contains member functions for name-value pairs. More...

#include <nvp.hpp>

Public Member Functions

template<typename U >
constexpr nvp_child< iterable_value_t< no_opt_type >, U, NvpT > operator->* (const nvp< iterable_value_t< no_opt_type >, U > &child) const
 Chains two name-value pairs to access a sub-field, i.e. More...
 
constexpr sort_expr< NvpT > sort (bool ascending) const
 Creates a sort expression that sorts documents by this field. More...
 
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr comparison_expr< NvpT, Iterable > in (const Iterable &iter) const
 Creates an expression that checks whether the value of this field matches any value in the given iterable. More...
 
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr comparison_expr< NvpT, Iterable > nin (const Iterable &iter) const
 Creates an expression that checks whether the value of this field matches none of the values in the given iterable. More...
 
template<typename U = T, typename = std::enable_if_t<is_optional_v<U>>>
constexpr comparison_expr< NvpT, bool > exists (const bool &exists) const
 Creates an expression that checks the existence of a certain field. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_arithmetic<U>::value>>
constexpr mod_expr< NvpT > mod (const int &divisor, const int &remainder) const
 Creates a mod_expr that represents a query with the $mod operator. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_string_v<U>>>
constexpr comparison_value_expr< NvpT, bsoncxx::types::b_regex > regex (const char *regex, const char *options) const
 Creates a comparison expression that represents a query with a $regex operator. More...
 
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>, typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr comparison_expr< NvpT, Iterable > all (const Iterable &iter) const
 Creates a query with the $all operator that compares values in this field's array to values in another array. More...
 
template<typename Expr , typename = std::enable_if_t<details::is_query_expression_v<Expr>>, typename U = no_opt_type, typename = std::enable_if_t<is_iterable_v<U>>>
constexpr comparison_expr< NvpT, Expr > elem_match (const Expr &queries) const
 Creates a query with the $elemMatch operator that finds elements in this field that match the given queries. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr free_nvp< iterable_value_t< no_opt_type > > element () const
 Constructs a nameless name-value-pair that corresponds to an element in a scalar array, if this field is an array. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr comparison_expr< NvpT, std::int64_t > size (const std::int64_t &n) const
 Creates an array query expression with the $size operator. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr< NvpT, Mask > bits_all_set (const Mask &bitmask) const
 Creates a query that uses the $bitsAllSet operator to check a numerical field with a bitmask. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr< NvpT, std::int64_t > bits_all_set (std::int64_t pos1, std::int64_t pos2, Args...positions) const
 Creates a query that uses the $bitsAllSet operator to check a series of bits, given as bit positions. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr< NvpT, Mask > bits_any_set (const Mask &bitmask) const
 Creates a query that uses the $bitsAnySet operator to check a numerical field with a bitmask. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr< NvpT, std::int64_t > bits_any_set (std::int64_t pos1, std::int64_t pos2, Args...positions) const
 Creates a query that uses the $bitsAnySet operator to check a series of bits, given as bit positions. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_value_expr< NvpT, Mask > bits_all_clear (const Mask &bitmask) const
 Creates a query that uses the $bitsAllClear operator to check a numerical field with a bitmask. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr< NvpT, std::int64_t > bits_all_clear (std::int64_t pos1, std::int64_t pos2, Args...positions) const
 Creates a query that uses the $bitsAllClear operator to check a series of bits, given as bit positions. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr< NvpT, Mask > bits_any_clear (const Mask &bitmask) const
 Creates a query that uses the $bitsAnyClear operator to check a numerical field with a bitmask. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr< NvpT, std::int64_t > bits_any_clear (std::int64_t pos1, std::int64_t pos2, Args...positions) const
 Creates a query that uses the $bitsAnyClear operator to check a series of bits, given as bit positions. More...
 
template<typename U = T, typename = std::enable_if_t<is_optional_v<U>>>
constexpr unset_expr< NvpT > unset () const
 Creates an expression that unsets the current field. More...
 
constexpr update_expr< NvpT, no_opt_type > min (const no_opt_type &val) const
 Creates an expression that uses the $min operator to only update a field if the new value is lower than the current value. More...
 
constexpr update_expr< NvpT, no_opt_type > max (const no_opt_type &val) const
 Creates an expression that uses the $max operator to only update a field if the new value is greater than the current value. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr dollar_operator_nvp< NvpT > first_match () const
 Returns a name-value pair with the $ operator appended to it. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr update_value_expr< NvpT, int > pop (bool last) const
 Creates an update expression with the $pop operator. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr update_expr< NvpT, iterable_value_t< no_opt_type > > pull (const iterable_value_t< no_opt_type > &val) const
 Creates an update expression with the $pull operator, that removes an element if it matches the given value exactly. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Expr >
constexpr std::enable_if_t< details::is_query_expression_v< Expr >, update_expr< NvpT, Expr > > pull (const Expr &expr) const
 Creates an update expression with the $pull operator, that removes an element if it matches the given query. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr update_expr< NvpT, Iterable > pull_all (const Iterable &iter) const
 Creates an update expression with the $pull operator, that removes an element if it matches the given value exactly. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr add_to_set_update_expr< NvpT, iterable_value_t< no_opt_type > > add_to_set (const iterable_value_t< no_opt_type > &val) const
 Creates an update expression with the $addToSet operator, that adds a single value to an array, if it is unique. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr add_to_set_update_expr< NvpT, Iterable > add_to_set (const Iterable &iter) const
 Creates an update expression with the $addToSet operator and the $each modifier, that adds a list of value to an array, only keeping the unique values. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr push_update_expr< NvpT, iterable_value_t< no_opt_type > > push (const iterable_value_t< no_opt_type > &val) const
 Creates an update epxression with the $push operator, that adds a single value to an array. More...
 
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>, typename Sort = int, typename = std::enable_if_t<details::is_sort_expression_v<Sort> || std::is_same<int, Sort>::value>>
constexpr push_update_expr< NvpT, Iterable, Sort > push (const Iterable &iter, 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) const
 Creates an update epxression with the $push operator and the $each modifier, that adds a list of value to an array. More...
 

Detailed Description

template<typename NvpT, typename T>
class mangrove::nvp_base< NvpT, T >

A CRTP base class that contains member functions for name-value pairs.

These functions are identical between nvp<...> and nvp_child<...>, but their return types are templated on the nvp's types, so they are defined here using CRTP.

Template Parameters
NvpTThe type of the name-value pair
TThe type of the field referred to by the name-value pair.

Member Function Documentation

template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr add_to_set_update_expr<NvpT, iterable_value_t<no_opt_type> > mangrove::nvp_base< NvpT, T >::add_to_set ( const iterable_value_t< no_opt_type > &  val) const
inline

Creates an update expression with the $addToSet operator, that adds a single value to an array, if it is unique.

This is only enabled if the current field is an array type.

Parameters
valThe value to add.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr add_to_set_update_expr<NvpT, Iterable> mangrove::nvp_base< NvpT, T >::add_to_set ( const Iterable &  iter) const
inline

Creates an update expression with the $addToSet operator and the $each modifier, that adds a list of value to an array, only keeping the unique values.

This is only enabled if the current field is an array.

Parameters
iterThe list of values to add.
template<typename NvpT, typename T>
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>, typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr comparison_expr<NvpT, Iterable> mangrove::nvp_base< NvpT, T >::all ( const Iterable &  iter) const
inline

Creates a query with the $all operator that compares values in this field's array to values in another array.

This is only enabled if the current field is an iterable itself.

Parameters
iterAn iterable containing elements of the same type as this field's elements.
Returns
A comparison expression with the $all oeprator.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_value_expr<NvpT, Mask> mangrove::nvp_base< NvpT, T >::bits_all_clear ( const Mask &  bitmask) const
inline

Creates a query that uses the $bitsAllClear operator to check a numerical field with a bitmask.

$bitsAllClear checks that every bit in the bitmask is cleared in the field's value.

Parameters
bitmask- A bitmask to pass to the $bitsAllClear operator
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr<NvpT, std::int64_t> mangrove::nvp_base< NvpT, T >::bits_all_clear ( std::int64_t  pos1,
std::int64_t  pos2,
Args...  positions 
) const
inline

Creates a query that uses the $bitsAllClear operator to check a series of bits, given as bit positions.

This function has two positional arguments to distinguish from the signature that takes a bit mask (see above)

Parameters
pos1The first bit position to check
pos2The second bit position to check
positions...Variadic argument containing further bit positions.
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr<NvpT, Mask> mangrove::nvp_base< NvpT, T >::bits_all_set ( const Mask &  bitmask) const
inline

Creates a query that uses the $bitsAllSet operator to check a numerical field with a bitmask.

$bitsAllSet checks that every bit in the bitmask is set in the field's value.

Parameters
bitmask- A bitmask to pass to the $bitsAllSet operator
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr<NvpT, std::int64_t> mangrove::nvp_base< NvpT, T >::bits_all_set ( std::int64_t  pos1,
std::int64_t  pos2,
Args...  positions 
) const
inline

Creates a query that uses the $bitsAllSet operator to check a series of bits, given as bit positions.

This function has two positional arguments to distinguish from the signature that takes a bit mask (see above)

Parameters
pos1The first bit position to check
pos2The second bit position to check
positions...Variadic argument containing further bit positions.
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr<NvpT, Mask> mangrove::nvp_base< NvpT, T >::bits_any_clear ( const Mask &  bitmask) const
inline

Creates a query that uses the $bitsAnyClear operator to check a numerical field with a bitmask.

$bitsAnyClear checks that a least one bit in the bitmask is cleared in the field's value.

Parameters
bitmask- A bitmask to pass to the $bitsAnyClear operator
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr<NvpT, std::int64_t> mangrove::nvp_base< NvpT, T >::bits_any_clear ( std::int64_t  pos1,
std::int64_t  pos2,
Args...  positions 
) const
inline

Creates a query that uses the $bitsAnyClear operator to check a series of bits, given as bit positions.

This function has two positional arguments to distinguish from the signature that takes a bit mask (see above)

Parameters
pos1The first bit position to check
pos2The second bit position to check
positions...Variadic argument containing further bit positions.
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename Mask , typename = std::enable_if_t<std::is_integral<Mask>::value || std::is_same<Mask, bsoncxx::types::b_binary>::value>>
constexpr comparison_expr<NvpT, Mask> mangrove::nvp_base< NvpT, T >::bits_any_set ( const Mask &  bitmask) const
inline

Creates a query that uses the $bitsAnySet operator to check a numerical field with a bitmask.

$bitsAnySet checks that a least one bit in the bitmask is set in the field's value.

Parameters
bitmask- A bitmask to pass to the $bitsAnySet operator
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_integral<U>::value || std::is_same<U, bsoncxx::types::b_binary>::value>, typename... Args>
constexpr comparison_value_expr<NvpT, std::int64_t> mangrove::nvp_base< NvpT, T >::bits_any_set ( std::int64_t  pos1,
std::int64_t  pos2,
Args...  positions 
) const
inline

Creates a query that uses the $bitsAnySet operator to check a series of bits, given as bit positions.

This function has two positional arguments to distinguish from the signature that takes a bit mask (see above)

Parameters
pos1The first bit position to check
pos2The second bit position to check
positions...Variadic argument containing further bit positions.
Returns
A comparison_expr representing this query
template<typename NvpT, typename T>
template<typename Expr , typename = std::enable_if_t<details::is_query_expression_v<Expr>>, typename U = no_opt_type, typename = std::enable_if_t<is_iterable_v<U>>>
constexpr comparison_expr<NvpT, Expr> mangrove::nvp_base< NvpT, T >::elem_match ( const Expr &  queries) const
inline

Creates a query with the $elemMatch operator that finds elements in this field that match the given queries.

This can include "free" expressions, that don't contain a field name, in the case of a scalar array. e.g. "arr: {$elemMatch: {$gt: 4, .....}}" This is only enabled if the current field is an iterable itself.

Template Parameters
ExprA query expression object.
Parameters
queriesQueries to comapre values against.
Returns
A comparison expression with the $elemMatch operator.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr free_nvp<iterable_value_t<no_opt_type> > mangrove::nvp_base< NvpT, T >::element ( ) const
inline

Constructs a nameless name-value-pair that corresponds to an element in a scalar array, if this field is an array.

This is used to create expressions with $elemMatch. This is only enabled if this current field is an array.

template<typename NvpT, typename T>
template<typename U = T, typename = std::enable_if_t<is_optional_v<U>>>
constexpr comparison_expr<NvpT, bool> mangrove::nvp_base< NvpT, T >::exists ( const bool &  exists) const
inline

Creates an expression that checks the existence of a certain field.

This is only enabled for fields that are optional types. {field: {$exists: <bool>}}

Parameters
existsIf false, checks that the given field does not exist in a document. True by default.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr dollar_operator_nvp<NvpT> mangrove::nvp_base< NvpT, T >::first_match ( ) const
inline

Returns a name-value pair with the $ operator appended to it.

When used in an update expression, this modifies the first array element that satisfies a query.

Returns
a dollar_operator_nvp that corresponds to "<field_name>.$"
template<typename NvpT, typename T>
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr comparison_expr<NvpT, Iterable> mangrove::nvp_base< NvpT, T >::in ( const Iterable &  iter) const
inline

Creates an expression that checks whether the value of this field matches any value in the given iterable.

Template Parameters
IterableA type that works in range-based for loops, and yields objects convertible to the type of this name-value pair.
template<typename NvpT, typename T>
constexpr update_expr<NvpT, no_opt_type> mangrove::nvp_base< NvpT, T >::max ( const no_opt_type &  val) const
inline

Creates an expression that uses the $max operator to only update a field if the new value is greater than the current value.

Parameters
valThe (tentative) new value.
Returns
An UpdateExpression with the $max operator.
template<typename NvpT, typename T>
constexpr update_expr<NvpT, no_opt_type> mangrove::nvp_base< NvpT, T >::min ( const no_opt_type &  val) const
inline

Creates an expression that uses the $min operator to only update a field if the new value is lower than the current value.

Parameters
valThe (tentative) new value.
Returns
An UpdateExpression with the $min operator.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<std::is_arithmetic<U>::value>>
constexpr mod_expr<NvpT> mangrove::nvp_base< NvpT, T >::mod ( const int &  divisor,
const int &  remainder 
) const
inline

Creates a mod_expr that represents a query with the $mod operator.

Such a query essentially checks that "nvp_value % divisor == remainder"

Parameters
divisorThe divisor for the modulus operation
remainderThe remainder after dividing a value by divisor
Returns
A mod_expr representing this query.
template<typename NvpT, typename T>
template<typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr comparison_expr<NvpT, Iterable> mangrove::nvp_base< NvpT, T >::nin ( const Iterable &  iter) const
inline

Creates an expression that checks whether the value of this field matches none of the values in the given iterable.

Template Parameters
IterableA type that works in range-based for loops, and yields objects convertible to the type of this name-value pair.
template<typename NvpT, typename T>
template<typename U >
constexpr nvp_child<iterable_value_t<no_opt_type>, U, NvpT> mangrove::nvp_base< NvpT, T >::operator->* ( const nvp< iterable_value_t< no_opt_type >, U > &  child) const
inline

Chains two name-value pairs to access a sub-field, i.e.

a field with the name "parent.child". This also allows accessing the fields of documents that are in an array.

Template Parameters
UThe type of the child NVP
Parameters
childAn NVP that corresponds to a sub-field of this NVP. Its base class must be the same as this field's current type. If this field is an array of documents, then 'child' corresponds to a subfield of the documents in this array.
Returns
An NVP with the same base class and type as the subfield, but with a link to a parent so that its name is qualified in dot notation.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr update_value_expr<NvpT, int> mangrove::nvp_base< NvpT, T >::pop ( bool  last) const
inline

Creates an update expression with the $pop operator.

This is only enabled if the current field is an array type.

Parameters
lastIf true, removes the element from the end of the array. If false, from the start.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr update_expr<NvpT, iterable_value_t<no_opt_type> > mangrove::nvp_base< NvpT, T >::pull ( const iterable_value_t< no_opt_type > &  val) const
inline

Creates an update expression with the $pull operator, that removes an element if it matches the given value exactly.

This is only enabled if the current field is an array type.

Parameters
valThe value to remove. This must match the type contained by this array field.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Expr >
constexpr std::enable_if_t<details::is_query_expression_v<Expr>, update_expr<NvpT, Expr> > mangrove::nvp_base< NvpT, T >::pull ( const Expr &  expr) const
inline

Creates an update expression with the $pull operator, that removes an element if it matches the given query.

This query can contain free expressions, similarly to the $elemMatch operator. This is only enabled if the current field is an array type.

Template Parameters
ExprThe type of the given query, must be a query expression.
Parameters
exprA query expression against which to compare
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>>
constexpr update_expr<NvpT, Iterable> mangrove::nvp_base< NvpT, T >::pull_all ( const Iterable &  iter) const
inline

Creates an update expression with the $pull operator, that removes an element if it matches the given value exactly.

This is only enabled if the current field is an array type.

Parameters
iterAn iterable containing the values to remove.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr push_update_expr<NvpT, iterable_value_t<no_opt_type> > mangrove::nvp_base< NvpT, T >::push ( const iterable_value_t< no_opt_type > &  val) const
inline

Creates an update epxression with the $push operator, that adds a single value to an array.

This is only enabled if the current field is an array.

Parameters
valThe value to add.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>, typename Iterable , typename = enable_if_matching_iterable_t<Iterable>, typename Sort = int, typename = std::enable_if_t<details::is_sort_expression_v<Sort> || std::is_same<int, Sort>::value>>
constexpr push_update_expr<NvpT, Iterable, Sort> mangrove::nvp_base< NvpT, T >::push ( const Iterable &  iter,
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 
) const
inline

Creates an update epxression with the $push operator and the $each modifier, that adds a list of value to an array.

Further modifiers can be given as arguments to this function, or by modifying the resulting push_update_expr object. This is only enabled if the current field is an array.

Template Parameters
IterableAn iterable that contains the same value type as this field's array.
SortThe type of the given sort expression, if one is given.
Parameters
iterThe iterable containing values to add.
sliceAn optional argument containing the value of the $slice modifier.
sortAn optional argument containing an expression for the $sort modifier.
positionAn optional argument containing the value of the $position modifier.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_string_v<U>>>
constexpr comparison_value_expr<NvpT, bsoncxx::types::b_regex> mangrove::nvp_base< NvpT, T >::regex ( const char *  regex,
const char *  options 
) const
inline

Creates a comparison expression that represents a query with a $regex operator.

Such a query only works for string fields.

Parameters
regexThe regex to check against.
optionsOptions to pass to the regex.
template<typename NvpT, typename T>
template<typename U = no_opt_type, typename = std::enable_if_t<is_iterable_not_string_v<U>>>
constexpr comparison_expr<NvpT, std::int64_t> mangrove::nvp_base< NvpT, T >::size ( const std::int64_t &  n) const
inline

Creates an array query expression with the $size operator.

This is only enabled if this current field is an array.

Parameters
nThe size the array should be.
template<typename NvpT, typename T>
constexpr sort_expr<NvpT> mangrove::nvp_base< NvpT, T >::sort ( bool  ascending) const
inline

Creates a sort expression that sorts documents by this field.

Parameters
ascendingWhether to sort by ascending order (+1 in MongoDB syntax). If false, sorts by descending order (-1 in MongoDB syntax).
Returns
a sort_expr that reprsents the sort expression {field: +/-1}.
template<typename NvpT, typename T>
template<typename U = T, typename = std::enable_if_t<is_optional_v<U>>>
constexpr unset_expr<NvpT> mangrove::nvp_base< NvpT, T >::unset ( ) const
inline

Creates an expression that unsets the current field.

The field must be of optional type.

Returns
An unset_expr that unsets the current field.

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