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

This class represents a query expression using the $mod operator, that checks the modulus of a certain numerical field. More...

#include <query_builder.hpp>

Public Member Functions

constexpr mod_expr (NvpT nvp, const int &divisor, const int &remainder)
 Constructs a mod_expr that represents a query with the $mod operator. More...
 
std::string & append_name (std::string &s) const
 Appends the name of the contained field to a string.
 
void append_to_bson (bsoncxx::builder::core &builder, bool wrap=false, bool omit_name=false) const
 Appends this expression to a BSON core builder, as a key-value pair of the form " key: { $mod: [ divisor, remainder ] } ". More...
 
 operator bsoncxx::document::view_or_value () const
 Converts the expression to a BSON filter for a query. More...
 

Detailed Description

template<typename NvpT>
class mangrove::mod_expr< NvpT >

This class represents a query expression using the $mod operator, that checks the modulus of a certain numerical field.

Constructor & Destructor Documentation

template<typename NvpT >
constexpr mangrove::mod_expr< NvpT >::mod_expr ( NvpT  nvp,
const int &  divisor,
const int &  remainder 
)
inline

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

Parameters
nvpThe name-value pair to compare against.
divisorThe divisor used in the modulus operation.
remainderThe remainder produced when dividing the field by the divisor.

Member Function Documentation

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

Appends this expression to a BSON core builder, as a key-value pair of the form " key: { $mod: [ divisor, remainder ] } ".

Parameters
buildera BSON core builder
wrapWhether to wrap the BSON inside a document.
template<typename NvpT >
mangrove::mod_expr< NvpT >::operator bsoncxx::document::view_or_value ( ) const
inline

Converts the expression to a BSON filter for a query.

The resulting BSON is of the form "{ key: { $mod: [ divisor, remainder ] } }".


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