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

An expression that represents a sorting order. More...

#include <query_builder.hpp>

Public Member Functions

constexpr sort_expr (const NvpT &nvp, bool ascending)
 Creates a sort expression with the given name-value-pair and sort order. More...
 
void append_to_bson (bsoncxx::builder::core &builder, bool wrap=false) const
 Appends this expression to a BSON core builder, as a key-value pair of the form "key: +/-1". 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::sort_expr< NvpT >

An expression that represents a sorting order.

This consists of a name-value pair and a boolean specifying ascending or descending sort order. The resulting BSON is {field: +/-1}, where +/-1 corresponds to the sort order.

Constructor & Destructor Documentation

template<typename NvpT >
constexpr mangrove::sort_expr< NvpT >::sort_expr ( const NvpT &  nvp,
bool  ascending 
)
inline

Creates a sort expression with the given name-value-pair and sort order.

Parameters
nvpThe name-value pair to order against.
ascendingWhether to use ascending (true) or descending (false) order.

Member Function Documentation

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

Appends this expression to a BSON core builder, as a key-value pair of the form "key: +/-1".

Parameters
builderA BSON core builder
wrapWhether to wrap the BSON inside a document.
template<typename NvpT >
mangrove::sort_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: +/-1}"


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