17 #include <mangrove/config/prelude.hpp> 23 #include <type_traits> 25 #include <bsoncxx/builder/core.hpp> 26 #include <bsoncxx/view_or_value.hpp> 28 #include <mangrove/expression_syntax.hpp> 29 #include <mangrove/nvp.hpp> 30 #include <mangrove/util.hpp> 33 MANGROVE_INLINE_NAMESPACE_BEGIN
40 auto is_bson_appendable_impl(
int)
41 -> decltype(std::declval<bsoncxx::builder::core>().append(std::declval<T>()), std::true_type{});
44 std::false_type is_bson_appendable_impl(...);
47 using is_bson_appendable = decltype(is_bson_appendable_impl<T>(0));
50 constexpr
bool is_bson_appendable_v = is_bson_appendable<T>::value;
61 std::enable_if_t<is_bson_appendable_v<T>> append_value_to_bson(T value,
62 bsoncxx::builder::core &builder) {
63 builder.append(value);
68 std::enable_if_t<!is_bson_appendable_v<T> && !is_iterable_not_string_v<T> &&
69 details::isnt_expression_v<T>>
70 append_value_to_bson(
const T &value, bsoncxx::builder::core &builder) {
71 auto serialized_value = boson::to_document<T>(value);
72 builder.append(bsoncxx::types::b_document{serialized_value});
76 template <
typename Iterable>
77 std::enable_if_t<is_iterable_not_string_v<Iterable>> append_value_to_bson(
78 const Iterable &arr, bsoncxx::builder::core &builder) {
80 for (
const auto &x : arr) {
81 append_value_to_bson(x, builder);
83 builder.close_array();
87 template <
typename Expression>
88 std::enable_if_t<!details::isnt_expression_v<Expression>> append_value_to_bson(
89 const Expression &expr, bsoncxx::builder::core &builder) {
90 builder.open_document();
91 expr.append_to_bson(builder);
92 builder.close_document();
96 template <
typename Clock,
typename Duration>
97 void append_value_to_bson(
const std::chrono::time_point<Clock, Duration> &tp,
98 bsoncxx::builder::core &builder) {
99 builder.append(bsoncxx::types::b_date(tp));
107 template <
typename NvpT>
110 using field_type = NvpT;
116 constexpr
sort_expr(
const NvpT &
nvp,
bool ascending) : _nvp(nvp), _ascending(ascending) {
127 builder.open_document();
131 builder.key_view(_nvp.append_name(s));
132 builder.append(_ascending ? 1 : -1);
135 builder.close_document();
143 operator bsoncxx::document::view_or_value()
const {
144 auto builder = bsoncxx::builder::core(
false);
146 return builder.extract_document();
151 const bool _ascending;
165 template <
typename NvpT,
typename U>
168 using field_type = NvpT;
176 : _nvp(nvp), _field(field), _operator(op) {
188 : _nvp(expr._nvp), _field(expr._field), _operator(op) {
195 return _nvp.append_name(s);
207 bool omit_name =
false)
const {
209 builder.open_document();
211 if (!omit_name && !is_free_nvp_v<field_type>) {
213 builder.key_view(_nvp.append_name(s));
214 builder.open_document();
217 builder.key_view(_operator);
218 append_value_to_bson(_field, builder);
220 if (!omit_name && !is_free_nvp_v<field_type>) {
221 builder.close_document();
224 builder.close_document();
232 operator bsoncxx::document::view_or_value()
const {
233 auto builder = bsoncxx::builder::core(
false);
235 return builder.extract_document();
241 const char *_operator;
249 template <
typename NvpT,
typename U>
265 template <
typename NvpT>
268 using field_type = NvpT;
275 constexpr
mod_expr(NvpT
nvp,
const int &divisor,
const int &remainder)
276 : _nvp(nvp), _divisor(divisor), _remainder(remainder) {
283 return _nvp.append_name(s);
293 bool omit_name =
false)
const {
295 builder.open_document();
297 if (!omit_name && !is_free_nvp_v<field_type>) {
299 builder.key_view(_nvp.append_name(s));
300 builder.open_document();
302 builder.key_view(
"$mod");
303 builder.open_array();
304 builder.append(_divisor);
305 builder.append(_remainder);
306 builder.close_array();
307 if (!omit_name && !is_free_nvp_v<field_type>) {
308 builder.close_document();
311 builder.close_document();
319 operator bsoncxx::document::view_or_value()
const {
320 auto builder = bsoncxx::builder::core(
false);
322 return builder.extract_document();
328 const int &_remainder;
348 bsoncxx::stdx::optional<const char *> language = bsoncxx::stdx::nullopt,
349 bsoncxx::stdx::optional<bool> case_sensitive = bsoncxx::stdx::nullopt,
350 bsoncxx::stdx::optional<bool> diacritic_sensitive = bsoncxx::stdx::nullopt)
353 _case_sensitive(case_sensitive),
354 _diacritic_sensitive(diacritic_sensitive) {
358 _language = bsoncxx::stdx::nullopt;
368 _case_sensitive = bsoncxx::stdx::nullopt;
373 _case_sensitive = case_sensitive;
378 _diacritic_sensitive = bsoncxx::stdx::nullopt;
383 _diacritic_sensitive = diacritic_sensitive;
395 builder.open_document();
397 builder.key_view(
"$text");
398 builder.open_document();
399 builder.key_view(
"$search");
400 builder.append(_search);
402 builder.key_view(
"$language");
403 builder.append(_language.value());
407 if (_case_sensitive) {
408 builder.key_view(
"$caseSensitive");
409 builder.append(_case_sensitive.value());
411 if (_diacritic_sensitive) {
412 builder.key_view(
"$diacriticSensitive");
413 builder.append(_diacritic_sensitive.value());
415 builder.close_document();
417 builder.close_document();
425 operator bsoncxx::document::view_or_value()
const {
426 auto builder = bsoncxx::builder::core(
false);
428 return builder.extract_document();
433 mongocxx::stdx::optional<const char *> _language;
434 bsoncxx::stdx::optional<bool> _case_sensitive;
435 bsoncxx::stdx::optional<bool> _diacritic_sensitive;
443 template <
typename Expr>
446 using field_type =
typename Expr::field_type;
452 constexpr
not_expr(
const Expr &expr) : _expr(expr) {
459 return _expr.append_name(s);
472 bool omit_name =
false)
const {
474 builder.open_document();
476 if (!omit_name && !is_free_nvp_v<field_type>) {
478 builder.key_view(_expr.append_name(s));
479 builder.open_document();
482 builder.key_view(
"$not");
484 _expr.append_to_bson(builder,
true,
true);
486 if (!omit_name && !is_free_nvp_v<field_type>) {
487 builder.close_document();
490 builder.close_document();
498 operator bsoncxx::document::view_or_value()
const {
499 auto builder = bsoncxx::builder::core(
false);
501 return builder.extract_document();
513 template <expression_category list_type,
typename... Args>
530 tuple_for_each(storage, [&](
const auto &v) { v.append_to_bson(builder, wrap); });
536 operator bsoncxx::document::view_or_value()
const {
537 auto builder = bsoncxx::builder::core(
false);
539 return builder.extract_document();
542 std::tuple<Args...> storage;
549 template <
typename Expr1,
typename Expr2>
558 constexpr
boolean_expr(
const Expr1 &lhs,
const Expr2 &rhs,
const char *op)
559 : _lhs(lhs), _rhs(rhs), _op(op) {
569 builder.open_document();
572 builder.key_view(_op);
573 builder.open_array();
576 builder.open_document();
577 _lhs.append_to_bson(builder, wrap);
578 builder.close_document();
581 builder.open_document();
582 _rhs.append_to_bson(builder, wrap);
583 builder.close_document();
585 builder.close_array();
588 builder.close_document();
596 operator bsoncxx::document::view_or_value()
const {
597 auto builder = bsoncxx::builder::core(
false);
599 return builder.extract_document();
612 template <
typename List>
630 builder.open_document();
632 builder.key_view(_op);
633 builder.open_array();
634 _args.append_to_bson(builder,
true);
635 builder.close_array();
637 builder.close_document();
645 operator bsoncxx::document::view_or_value()
const {
646 auto builder = bsoncxx::builder::core(
false);
648 return builder.extract_document();
658 template <
typename Expr>
672 builder.open_document();
675 _expr.append_to_bson(builder,
false);
676 builder.key_view(
"$isolated");
680 builder.close_document();
687 operator bsoncxx::document::view_or_value()
const {
688 auto builder = bsoncxx::builder::core(
false);
690 return {builder.extract_document()};
708 template <
typename NvpT,
typename U>
711 using field_type = NvpT;
712 constexpr
update_expr(
const NvpT &
nvp,
const U &val,
const char *op)
713 : _nvp(nvp), _val(val), _op(op) {
723 builder.open_document();
725 builder.key_view(_op);
726 builder.open_document();
728 builder.key_view(_nvp.append_name(s));
729 append_value_to_bson(_val, builder);
730 builder.close_document();
732 builder.close_document();
739 operator bsoncxx::document::view_or_value()
const {
740 auto builder = bsoncxx::builder::core(
false);
742 return {builder.extract_document()};
751 template <
typename NvpT,
typename U>
765 template <
typename NvpT>
768 using field_type = NvpT;
779 builder.open_document();
781 builder.key_view(
"$unset");
782 builder.open_document();
784 builder.key_view(_nvp.append_name(s));
786 builder.close_document();
788 builder.close_document();
792 operator bsoncxx::document::view_or_value()
const {
793 auto builder = bsoncxx::builder::core(
false);
795 return {builder.extract_document()};
805 template <
typename NvpT>
808 using field_type = NvpT;
825 builder.open_document();
827 builder.key_view(
"$currentDate");
828 builder.open_document();
830 builder.key_view(_nvp.append_name(s));
833 builder.open_document();
834 builder.key_view(
"$type");
835 builder.append(_is_date ?
"date" :
"timestamp");
836 builder.close_document();
838 builder.close_document();
840 builder.close_document();
844 operator bsoncxx::document::view_or_value()
const {
845 auto builder = bsoncxx::builder::core(
false);
847 return {builder.extract_document()};
860 template <
typename NvpT,
typename U>
863 using field_type = NvpT;
871 : _nvp(nvp), _val(val), _each(each) {
882 builder.open_document();
884 builder.key_view(
"$addToSet");
885 builder.open_document();
887 builder.key_view(_nvp.append_name(s));
891 builder.open_document();
892 builder.key_view(
"$each");
894 append_value_to_bson(_val, builder);
896 builder.close_document();
899 builder.close_document();
901 builder.close_document();
905 operator bsoncxx::document::view_or_value()
const {
906 auto builder = bsoncxx::builder::core(
false);
908 return {builder.extract_document()};
926 template <
typename NvpT,
typename U,
typename Sort>
929 using field_type = NvpT;
944 const NvpT &
nvp,
const U &val,
bool each,
945 bsoncxx::stdx::optional<std::int32_t> slice = bsoncxx::stdx::nullopt,
946 const bsoncxx::stdx::optional<Sort> &sort = bsoncxx::stdx::nullopt,
947 bsoncxx::stdx::optional<std::uint32_t> position = bsoncxx::stdx::nullopt)
948 : _nvp(nvp), _val(val), _each(each), _slice(slice), _sort(sort), _position(position) {
961 return {_nvp, _val, _each, slice, _sort, _position};
970 return {_nvp, _val, _each, bsoncxx::stdx::nullopt, _sort, _position};
980 template <
typename OtherNvpT>
983 return {_nvp, _val, _each, _slice, sort, _position};
993 return {_nvp, _val, _each, _slice, sort, _position};
1002 return {_nvp, _val, _each, _slice, bsoncxx::stdx::nullopt, _position};
1012 return {_nvp, _val, _each, _slice, _sort, position};
1021 return {_nvp, _val, _each, _slice, _sort, bsoncxx::stdx::nullopt};
1032 builder.open_document();
1034 builder.key_view(
"$push");
1035 builder.open_document();
1037 builder.key_view(_nvp.append_name(s));
1041 builder.open_document();
1042 builder.key_view(
"$each");
1044 append_value_to_bson(_val, builder);
1047 builder.key_view(
"$slice");
1048 builder.append(_slice.value());
1051 builder.key_view(
"$sort");
1052 append_value_to_bson(_sort.value(), builder);
1055 builder.key_view(
"$position");
1056 builder.append(static_cast<std::int64_t>(_position.value()));
1058 builder.close_document();
1061 builder.close_document();
1063 builder.close_document();
1067 operator bsoncxx::document::view_or_value()
const {
1068 auto builder = bsoncxx::builder::core(
false);
1070 return {builder.extract_document()};
1077 const bsoncxx::stdx::optional<std::int32_t> _slice;
1078 const bsoncxx::stdx::optional<Sort> _sort;
1079 const bsoncxx::stdx::optional<std::uint32_t> _position;
1088 template <
typename NvpT,
typename Integer>
1091 using field_type = NvpT;
1093 : _nvp(nvp), _mask(mask), _operation(op){};
1103 builder.open_document();
1105 builder.key_view(
"$bit");
1106 builder.open_document();
1108 builder.key_view(_nvp.append_name(s));
1111 builder.open_document();
1112 builder.key_view(_operation);
1113 builder.append(_mask);
1114 builder.close_document();
1116 builder.close_document();
1118 builder.close_document();
1122 operator bsoncxx::document::view_or_value()
const {
1123 auto builder = bsoncxx::builder::core(
false);
1125 return {builder.extract_document()};
1130 const Integer _mask;
1131 const char *_operation;
1136 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1138 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1139 return {lhs, rhs,
"$eq"};
1142 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1144 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1145 return eq(lhs, rhs);
1148 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1150 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1151 return {lhs, rhs,
"$gt"};
1154 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1156 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1157 return gt(lhs, rhs);
1160 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1162 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1163 return {lhs, rhs,
"$gte"};
1166 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1168 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1169 return gte(lhs, rhs);
1172 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1174 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1175 return {lhs, rhs,
"$lt"};
1178 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1180 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1181 return lt(lhs, rhs);
1184 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1186 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1187 return {lhs, rhs,
"$lte"};
1190 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1192 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1193 return lte(lhs, rhs);
1196 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1198 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1199 return {lhs, rhs,
"$ne"};
1202 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1204 const NvpT &lhs,
const typename NvpT::no_opt_type &rhs) {
1205 return ne(lhs, rhs);
1212 template <
typename Expr,
typename = std::enable_if_t<details::is_query_expression_v<Expr>>>
1220 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>>
1223 return {regex_expr,
"$not"};
1226 template <
typename Expr, expression_category list_type,
typename... Args,
size_t... idxs>
1229 return {expr, std::get<idxs>(list.storage)...};
1236 template <
typename Expr, expression_category list_type,
1237 typename = std::enable_if_t<details::is_expression_type<list_type, Expr>::value>,
1241 return append_impl(list, expr, std::index_sequence_for<Args...>());
1244 template <
typename Expr1,
typename Expr2,
1245 typename = std::enable_if_t<!details::isnt_expression_v<Expr1> &&
1248 constexpr
expression_list<details::expression_type<Expr1>::value, Expr1, Expr2>
operator,(
1249 Expr1 &&expr1, Expr2 &&expr2) {
1250 return {expr1, expr2};
1256 template <
typename Expr1,
typename Expr2,
1257 typename = std::enable_if_t<details::is_query_expression_v<Expr1> &&
1258 details::is_query_expression_v<Expr2>>>
1260 return {lhs, rhs,
"$and"};
1263 template <
typename Expr1,
typename Expr2,
1264 typename = std::enable_if_t<details::is_query_expression_v<Expr1> &&
1265 details::is_query_expression_v<Expr2>>>
1267 return {lhs, rhs,
"$or"};
1281 template <
typename... Args>
1284 return {list,
"$nor"};
1290 template <
typename... QueryExpressions,
1293 QueryExpressions... args) {
1294 return {{args...},
"$nor"};
1311 const char *search, bsoncxx::stdx::optional<const char *> language = bsoncxx::stdx::nullopt,
1312 bsoncxx::stdx::optional<bool> case_sensitive = bsoncxx::stdx::nullopt,
1313 bsoncxx::stdx::optional<bool> diacritic_sensitive = bsoncxx::stdx::nullopt) {
1314 return {search, language, case_sensitive, diacritic_sensitive};
1320 template <
typename Expr,
typename = std::enable_if_t<details::is_query_expression_v<Expr>>>
1327 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1328 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1330 const NvpT &
nvp,
const typename NvpT::no_opt_type &val) {
1331 return {nvp, val,
"$inc"};
1334 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1335 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1337 const NvpT &nvp,
const typename NvpT::no_opt_type &val) {
1338 return {nvp, -val,
"$inc"};
1341 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1342 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1344 return {nvp, 1,
"$inc"};
1347 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1348 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1350 return {nvp, 1,
"$inc"};
1353 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1354 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1356 return {nvp, -1,
"$inc"};
1359 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1360 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1362 return {nvp, -1,
"$inc"};
1365 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1366 typename = std::enable_if_t<std::is_arithmetic<
typename NvpT::no_opt_type>::value>>
1368 const NvpT &nvp,
const typename NvpT::no_opt_type &val) {
1369 return {nvp, val,
"$mul"};
1374 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1375 typename = std::enable_if_t<std::is_
integral<
typename NvpT::no_opt_type>::value>>
1377 const NvpT &nvp,
const typename NvpT::no_opt_type &mask) {
1378 return {nvp, mask,
"and"};
1381 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1382 typename = std::enable_if_t<std::is_
integral<
typename NvpT::no_opt_type>::value>>
1384 const NvpT &nvp,
const typename NvpT::no_opt_type &mask) {
1385 return {nvp, mask,
"or"};
1388 template <
typename NvpT,
typename = std::enable_if_t<is_nvp_v<NvpT>>,
1389 typename = std::enable_if_t<std::is_
integral<
typename NvpT::no_opt_type>::value>>
1391 const NvpT &nvp,
const typename NvpT::no_opt_type &mask) {
1392 return {nvp, mask,
"xor"};
1395 MANGROVE_INLINE_NAMESPACE_END
1398 #include <mangrove/config/postlude.hpp> 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.
Definition: query_builder.hpp:943
Represents an array update epression that uses the $push operator.
Definition: expression_syntax.hpp:89
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends each element to a BSON code builder.
Definition: query_builder.hpp:529
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"...
Definition: query_builder.hpp:125
expression_list(const Args &...args)
Constructs an expression list of the given arguments.
Definition: query_builder.hpp:520
Creates an expression that uses the $currentDate operator.
Definition: expression_syntax.hpp:83
Represents a query that performs a text search with the $text operator.
Definition: query_builder.hpp:335
An object that represents a name-value pair of a member in an object.
Definition: nvp.hpp:47
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: {$cmp: val}"...
Definition: query_builder.hpp:206
This class represents a query expression using the $mod operator, that checks the modulus of a certai...
Definition: expression_syntax.hpp:60
constexpr sort_expr(const NvpT &nvp, bool ascending)
Creates a sort expression with the given name-value-pair and sort order.
Definition: query_builder.hpp:116
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as an expression '.
Definition: query_builder.hpp:823
constexpr boolean_list_expr(const List args, const char *op)
Constructs a boolean expression from a list of sub-expressions, and a certain operator.
Definition: query_builder.hpp:620
constexpr push_update_expr< NvpT, U, Sort > slice()
Create a copy of this expression without a $slice modifier.
Definition: query_builder.hpp:969
constexpr mod_expr(NvpT nvp, const int &divisor, const int &remainder)
Constructs a mod_expr that represents a query with the $mod operator.
Definition: query_builder.hpp:275
constexpr push_update_expr< NvpT, U, Sort > position()
Create a copy of this expression without $position modifier.
Definition: query_builder.hpp:1020
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as a key-value pair "$op: [{lhs}, {rhs}]".
Definition: query_builder.hpp:567
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.
Definition: query_builder.hpp:981
An expression that uses the $addToSet operator to add unique elements to an array.
Definition: expression_syntax.hpp:86
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder, with $isolated set as an extra field.
Definition: query_builder.hpp:670
This represents a boolean expression with two arguments.
Definition: expression_syntax.hpp:68
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: {$not: {$cmp: v...
Definition: query_builder.hpp:471
constexpr comparison_expr(const comparison_expr &expr, const char *op)
Takes a comparison expression, and creates a new one with a different operator, but the same value an...
Definition: query_builder.hpp:187
An expression that wraps another expression and adds an $isolated operator.
Definition: query_builder.hpp:659
Represents an expresion that uses the $unset operator.
Definition: expression_syntax.hpp:80
constexpr push_update_expr< NvpT, U, Sort > sort()
Create a copy of this expression without a $sort modifier.
Definition: query_builder.hpp:1001
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as an expression '.
Definition: query_builder.hpp:1030
std::string & append_name(std::string &s) const
Appends the name of the contained field to a string.
Definition: query_builder.hpp:194
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as an expression '$bit: { <field>: { <and|or|xor>: <int> } ...
Definition: query_builder.hpp:1101
A type traits struct that determines whether a certain type stores a date.
Definition: util.hpp:153
Represents an update operator that modifies a certain elements.
Definition: expression_syntax.hpp:74
Expression that updates field using the $bit operator, which does bitwise operations using a mask...
Definition: expression_syntax.hpp:92
Definition: collection_wrapper.hpp:28
This represents an expression with the $not operator, which wraps a comparison expression and negates...
Definition: expression_syntax.hpp:63
constexpr current_date_expr(const NvpT &nvp, bool is_date)
Creates an expression that uses the $currentDate operator with a given field and type.
Definition: query_builder.hpp:814
constexpr push_update_expr< NvpT, U, Sort > position(std::uint32_t position)
Create a copy of this expression with a different $position modifier value.
Definition: query_builder.hpp:1011
constexpr push_update_expr< NvpT, U, Sort > slice(std::int32_t slice)
Create a copy of this expression with a different $slice modifier value.
Definition: query_builder.hpp:960
constexpr comparison_expr(const NvpT &nvp, const U &field, const char *op)
Constructs a query expression for the given key, value, and comparison type.
Definition: query_builder.hpp:175
Represents a comparison expression as above, but stores a value instead of a reference.
Definition: expression_syntax.hpp:57
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as a key-value pair "$op: {field: value}".
Definition: query_builder.hpp:721
A templated struct for determining whether a variadic list of boolean conditions is all true...
Definition: util.hpp:40
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: { $mod: [ divi...
Definition: query_builder.hpp:393
Definition: expression_syntax.hpp:109
This class represents a boolean expression over an array of arguments.
Definition: expression_syntax.hpp:71
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as a key-value pair "$unset: {field: ''}".
Definition: query_builder.hpp:777
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: [ divi...
Definition: query_builder.hpp:292
std::string & append_name(std::string &s) const
Appends the name of the contained field to a string.
Definition: query_builder.hpp:458
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as an expression '.
Definition: query_builder.hpp:880
constexpr add_to_set_update_expr(const NvpT &nvp, const U &val, bool each)
Constructs an add_to_set_update_expr with the given parameters.
Definition: query_builder.hpp:870
Definition: expression_syntax.hpp:77
constexpr not_expr(const Expr &expr)
Creates a $not expression that negates the given comparison expression.
Definition: query_builder.hpp:452
constexpr boolean_expr(const Expr1 &lhs, const Expr2 &rhs, const char *op)
Constructs a boolean expression from two other expressions, and a certain operator.
Definition: query_builder.hpp:558
text_search_expr(const char *search, bsoncxx::stdx::optional< const char * > language=bsoncxx::stdx::nullopt, bsoncxx::stdx::optional< bool > case_sensitive=bsoncxx::stdx::nullopt, bsoncxx::stdx::optional< bool > diacritic_sensitive=bsoncxx::stdx::nullopt)
Creates a text search expression.
Definition: query_builder.hpp:347
constexpr push_update_expr< NvpT, U, int > sort(int sort)
Create a copy of this expression with a different $slice modifier value.
Definition: query_builder.hpp:992
An expression that represents a sorting order.
Definition: expression_syntax.hpp:48
std::string & append_name(std::string &s) const
Appends the name of the contained field to a string.
Definition: query_builder.hpp:282
Represents a query expression with the syntax "key: {$op: value}".
Definition: expression_syntax.hpp:54
void append_to_bson(bsoncxx::builder::core &builder, bool wrap=false) const
Appends this query to a BSON core builder as a key-value pair "$op: [{lhs}, {rhs}]".
Definition: query_builder.hpp:628
This represents a list of expressions.
Definition: expression_syntax.hpp:51