![]() |
Mangrove
The C++ Object Document Mapper for MongoDB
|
Public Member Functions | |
template<typename... Ts, typename = std::enable_if_t<!first_two_types_are_same<model, Ts...>::value>> | |
model (Ts &&...ts) | |
Forward the arguments to the constructor of IdType. More... | |
void | remove () |
Deletes this object from the underlying collection. More... | |
void | save () |
Performs an update in the database that saves the current T object instance to the collection mapped to this class. More... | |
Static Public Member Functions | |
static std::int64_t | count (bsoncxx::document::view_or_value filter=bsoncxx::document::view_or_value{}, const mongocxx::options::count &options=mongocxx::options::count()) |
Counts the number of documents matching the provided filter. More... | |
static const mongocxx::collection | collection () |
Returns a copy of the underlying collection. More... | |
static mongocxx::stdx::optional< mongocxx::result::delete_result > | delete_many (bsoncxx::document::view_or_value filter, const mongocxx::options::delete_options &options=mongocxx::options::delete_options()) |
Deletes all matching documents from the collection. More... | |
static mongocxx::stdx::optional< mongocxx::result::delete_result > | delete_one (bsoncxx::document::view_or_value filter, const mongocxx::options::delete_options &options=mongocxx::options::delete_options()) |
Deletes a single matching document from the collection. More... | |
static void | drop () |
Drops the underlying collection and all its contained documents from the database. More... | |
static deserializing_cursor< T > | find (bsoncxx::document::view_or_value filter, const mongocxx::options::find &options=mongocxx::options::find()) |
Finds the documents in this collection which match the provided filter. More... | |
static mongocxx::stdx::optional< T > | find_one (bsoncxx::document::view_or_value filter, const mongocxx::options::find &options=mongocxx::options::find()) |
Finds a single document in this collection that matches the provided filter. More... | |
template<typename container_type , typename = std::enable_if_t<container_of_v<container_type, T>>> | |
static mongocxx::stdx::optional< mongocxx::result::insert_many > | insert_many (const container_type &container, const mongocxx::options::insert &options=mongocxx::options::insert()) |
Inserts multiple object of the model into the collection. More... | |
template<typename object_iterator_type , typename = std::enable_if_t<iterator_of_v<object_iterator_type, T>>> | |
static mongocxx::stdx::optional< mongocxx::result::insert_many > | insert_many (object_iterator_type begin, object_iterator_type end, const mongocxx::options::insert &options=mongocxx::options::insert()) |
Inserts multiple objects of the model into the collection. More... | |
static mongocxx::stdx::optional< mongocxx::result::insert_one > | insert_one (T obj, const mongocxx::options::insert &options=mongocxx::options::insert()) |
Inserts a single object of the model into the collection. More... | |
static void | setCollection (const mongocxx::collection &coll) |
Sets the underlying mongocxx::collection used to store and load instances of T. More... | |
static mongocxx::stdx::optional< mongocxx::result::update > | update_many (bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const mongocxx::options::update &options=mongocxx::options::update()) |
Updates multiple documents matching the provided filter in this collection. More... | |
static mongocxx::stdx::optional< mongocxx::result::update > | update_one (bsoncxx::document::view_or_value filter, bsoncxx::document::view_or_value update, const mongocxx::options::update &options=mongocxx::options::update()) |
Updates a single document matching the provided filter in this collection. More... | |
|
inline |
Forward the arguments to the constructor of IdType.
A std::enable_if is included to disable the template for the copy constructor case so the default is used.
ts | The variadic pack of arguments to be forwarded to the constructor of IdType. |
|
inlinestatic |
Returns a copy of the underlying collection.
|
inlinestatic |
Counts the number of documents matching the provided filter.
filter | The filter that documents must match in order to be counted. If a filter is not provided, count() will count the number of documents in the entire collection. |
options | Optional arguments, see mongocxx::options::count. |
mongocxx::exception::query | if the count operation fails. |
|
inlinestatic |
Deletes all matching documents from the collection.
filter | Document view representing the data to be deleted. |
options | Optional arguments, see mongocxx::options::delete_options. |
mongocxx::exception::write | if the delete fails. |
|
inlinestatic |
Deletes a single matching document from the collection.
filter | Document view representing the data to be deleted. |
options | Optional arguments, see mongocxx::options::delete_options. |
mongocxx::exception::write | if the delete fails. |
|
inlinestatic |
Drops the underlying collection and all its contained documents from the database.
exception::operation | if the operation fails. |
|
inlinestatic |
Finds the documents in this collection which match the provided filter.
filter | Document view representing a document that should match the query. |
options | Optional arguments, see mongocxx::options::find |
If | the find failed, the returned cursor will throw mongocxx::exception::query when it is iterated. |
|
inlinestatic |
Finds a single document in this collection that matches the provided filter.
filter | Document view representing a document that should match the query. |
options | Optional arguments, see mongocxx::options::find |
mongocxx::exception::query | if the operation fails. |
|
inlinestatic |
Inserts multiple object of the model into the collection.
containter_type | The container type. Must contain an iterator that yields objects of this model. |
container | Container of model objects to insert. |
options | Optional arguments, see mongocxx::options::insert. |
mongocxx::exception::write | when the operation fails. |
|
inlinestatic |
Inserts multiple objects of the model into the collection.
object_iterator_type | The iterator type. Must meet the requirements for the input iterator concept with the model class as the value type. |
begin | Iterator pointing to the first document to be inserted. |
end | Iterator pointing to the end of the documents to be inserted. |
options | Optional arguments, see mongocxx::options::insert. |
mongocxx::exception::write | if the operation fails. |
|
inlinestatic |
Inserts a single object of the model into the collection.
obj | The object of the model to insert. |
options | Optional arguments, see mongocxx::options::insert. |
mongocxx::exception::write | if the operation fails. |
|
inline |
Deletes this object from the underlying collection.
In the terms of the CRUD specification, this uses deleteOne with the _id as the sole argument to the query filter.
|
inline |
Performs an update in the database that saves the current T object instance to the collection mapped to this class.
In the terms of the CRUD specification, this uses updateOne with the _id as the sole argument to the query filter, the T object serialized to dotted notation BSON as the $set operand, and upsert=true so that objects that aren't already in the collection are automatically inserted.
|
inlinestatic |
Sets the underlying mongocxx::collection used to store and load instances of T.
coll | The mongocxx::collection object to be mapped to this class. |
|
inlinestatic |
Updates multiple documents matching the provided filter in this collection.
filter | Document representing the match criteria. |
update | Document representing the update to be applied to matching documents. |
options | Optional arguments, see mongocxx::options::update. |
exception::write | if the update operation fails. |
|
inlinestatic |
Updates a single document matching the provided filter in this collection.
filter | Document representing the match criteria. |
update | Document representing the update to be applied to a matching document. |
options | Optional arguments, see mongocxx::options::update. |
mongocxx::exception::write | if the update operation fails. |