31#ifndef MYSQLX_COLLECTION_CRUD_H
32#define MYSQLX_COLLECTION_CRUD_H
86common::Value Value::get<common::Value>() const;
104struct Collection_add_base
105 :
public Executable<Result, CollectionAdd>
137 :
public internal::Collection_add_base
138 , internal::Collection_add_detail
149 reset(internal::Crud_factory::mk_add(coll));
156 internal::Collection_add_base::operator=(other);
161 internal::Collection_add_base::operator=(std::move(other));
164 using internal::Collection_add_base::operator=;
171 template <
typename It>
175 do_add(get_impl(), begin, end);
188 template <
class Container>
192 do_add(get_impl(), c);
204 template <
typename... Types>
208 do_add(get_impl(), docs...);
216 using Impl = common::Collection_add_if;
220 return static_cast<Impl*
>(internal::Collection_add_base::get_impl());
238struct Collection_remove_cmd
242struct Collection_remove_base
243 :
public Sort< Limit< Bind_parameters< Collection_remove_cmd > > >
260 :
public internal::Collection_remove_base
275 reset(internal::Crud_factory::mk_remove(coll, expr));
283 internal::Collection_remove_cmd::operator=(other);
288 internal::Collection_remove_cmd::operator=(std::move(other));
291 using internal::Collection_remove_cmd::operator=;
307struct Collection_find_cmd
308 :
public Executable<DocResult, CollectionFind>
311struct Collection_find_base
312 :
public Group_by< Having< Sort< Limit< Offset< Bind_parameters<
313 Set_lock< Collection_find_cmd, common::Collection_find_if >
327 :
public internal::Collection_find_base
328 , internal::Collection_find_detail
331 using Operation = internal::Collection_find_base;
342 reset(internal::Crud_factory::mk_find(coll));
357 reset(internal::Crud_factory::mk_find(coll, expr));
365 internal::Collection_find_cmd::operator=(other);
370 internal::Collection_find_cmd::operator=(std::move(other));
373 using internal::Collection_find_cmd::operator=;
389 template <
typename... Expr>
393 get_impl()->clear_proj();
394 do_fields(get_impl(), proj...);
402 using Impl = common::Collection_find_if;
406 return static_cast<Impl*
>(internal::Collection_find_base::get_impl());
424class CollectionReplace;
426struct Collection_modify_cmd
430struct Collection_modify_base
431 :
public Sort< Limit< Bind_parameters< Collection_modify_cmd > > >
462 :
public internal::Collection_modify_base
477 reset(internal::Crud_factory::mk_modify(coll, expr));
485 internal::Collection_modify_cmd::operator=(other);
490 internal::Collection_modify_cmd::operator=(std::move(other));
493 using internal::Collection_modify_cmd::operator=;
506 get_impl()->add_operation(Impl::SET, field,
507 val.
get<common::Value>());
522 get_impl()->add_operation(Impl::UNSET, field);
538 get_impl()->add_operation(Impl::ARRAY_INSERT, field,
539 val.
get<common::Value>());
556 get_impl()->add_operation(Impl::ARRAY_APPEND, field,
557 val.
get<common::Value>());
584 get_impl()->add_operation(
585 Impl::MERGE_PATCH,
"$", (
const common::Value&)expr(val)
594 using Impl = common::Collection_modify_if;
598 return static_cast<Impl*
>(internal::Collection_modify_base::get_impl());
An operation which adds documents to a collection.
Definition: collection_crud.h:139
CollectionAdd & add(const Types &... docs)
Add document(s) to a collection.
Definition: collection_crud.h:205
CollectionAdd & add(const Container &c)
Add all documents within given container.
Definition: collection_crud.h:189
CollectionAdd(Collection &coll)
Create an empty add operation for the given collection.
Definition: collection_crud.h:146
CollectionAdd & add(const It &begin, const It &end)
Add all documents from a range defined by two iterators.
Definition: collection_crud.h:172
An operation which returns all or selected documents from a collection.
Definition: collection_crud.h:329
CollectionFind(Collection &coll)
Create an operation which returns all documents from the given collection.
Definition: collection_crud.h:339
CollectionFind(Collection &coll, const string &expr)
Create an operation which returns selected documents from the given collection.
Definition: collection_crud.h:354
Operation & fields(Expr... proj)
Specify a projection for the documents returned by this operation.
Definition: collection_crud.h:390
Represents a collection of documents in a schema.
Definition: xdevapi.h:908
An operation which modifies all or selected documents in a collection.
Definition: collection_crud.h:463
CollectionModify & unset(const Field &field)
Remove the given field from a document.
Definition: collection_crud.h:519
CollectionModify & set(const Field &field, const Value &val)
Set the given field in a document to the given value.
Definition: collection_crud.h:503
CollectionModify & arrayAppend(const Field &field, const Value &val)
Append a value to an array field of a document.
Definition: collection_crud.h:553
CollectionModify(Collection &coll, const string &expr)
Create an operation which modifies selected documents in the given collection.
Definition: collection_crud.h:474
CollectionModify & arrayInsert(const Field &field, const Value &val)
Insert a value into an array field of a document.
Definition: collection_crud.h:535
CollectionModify & patch(const string &val)
Apply JSON Patch to a target JSON document.
Definition: collection_crud.h:581
An operation which removes documents from a collection.
Definition: collection_crud.h:261
CollectionRemove(Collection &coll, const string &expr)
Create an operation which removes selected documnets from the given collection.
Definition: collection_crud.h:272
Represents an operation that can be executed.
Definition: executable.h:68
Value object can store value of scalar type, string, array or document.
Definition: document.h:228
T get() const
Return type of the value stored in this instance (or VNULL if no value is stored).
Details for public API classes representing CRUD operations.
Class representing executable statements.
Classes used to access query and command execution results.