|
NeoN
A framework for CFD software
|
A mixin class for collection of documents in a database to simplify the implementation of common operations. More...
#include <collection.hpp>
Public Member Functions | |
| CollectionMixin (NeoN::Database &db, std::string name) | |
| Constructs a CollectionMixin with the given database and collection name. | |
| CollectionMixin (const CollectionMixin &)=delete | |
| CollectionMixin & | operator= (const CollectionMixin &)=delete |
| CollectionMixin (CollectionMixin &&)=default | |
| CollectionMixin & | operator= (CollectionMixin &&)=delete |
| Document & | doc (const std::string &id) |
| Retrieves a document by its ID. | |
| const Document & | doc (const std::string &id) const |
| Retrieves a document by its ID (const version). | |
| std::vector< std::string > | find (const std::function< bool(const Document &)> &predicate) const |
| Finds documents that match a given predicate. | |
| std::size_t | size () const |
| Gets the number of documents in the collection. | |
| const NeoN::Database & | db () const |
| Gets a const reference to the database. | |
| NeoN::Database & | db () |
| Gets a reference to the database. | |
| const std::string & | name () const |
| Gets the name of the collection. | |
| std::string | type () const |
| Gets the type name of the documents in the collection. | |
| std::vector< std::string > | sortedKeys () const |
| Gets the sorted keys of the documents in the collection. | |
Protected Attributes | |
| std::unordered_map< std::string, DocumentType > | docs_ |
| The map of document IDs to documents. | |
| NeoN::Database & | db_ |
| The reference to the database. | |
| std::string | name_ |
| The name of the collection. | |
A mixin class for collection of documents in a database to simplify the implementation of common operations.
| DocumentType | The type of documents stored in the collection. |
Definition at line 215 of file collection.hpp.
|
inline |
Constructs a CollectionMixin with the given database and collection name.
| db | The database reference. |
| name | The name of the collection. |
Definition at line 226 of file collection.hpp.
|
delete |
@biref A CollectionMixin is not copyable, only moveable.
|
default |
@biref A CollectionMixin is moveable, but not copyable.
|
inline |
Gets a reference to the database.
Definition at line 302 of file collection.hpp.
|
inline |
Gets a const reference to the database.
Definition at line 295 of file collection.hpp.
|
inline |
Retrieves a document by its ID.
| id | The ID of the document. |
Definition at line 254 of file collection.hpp.
|
inline |
Retrieves a document by its ID (const version).
| id | The ID of the document. |
Definition at line 262 of file collection.hpp.
|
inline |
Finds documents that match a given predicate.
| predicate | A function that takes a const reference to a Document and returns a bool. |
Definition at line 270 of file collection.hpp.
|
inline |
Gets the name of the collection.
Definition at line 309 of file collection.hpp.
|
delete |
@biref A CollectionMixin is not move-assign-able.
|
delete |
@biref A CollectionMixin is not copyable, only moveable.
|
inline |
Gets the number of documents in the collection.
Definition at line 288 of file collection.hpp.
|
inline |
Gets the sorted keys of the documents in the collection.
Definition at line 323 of file collection.hpp.
|
inline |
Gets the type name of the documents in the collection.
Definition at line 316 of file collection.hpp.
|
protected |
The reference to the database.
Definition at line 337 of file collection.hpp.
|
protected |
The map of document IDs to documents.
Definition at line 336 of file collection.hpp.
|
protected |
The name of the collection.
Definition at line 338 of file collection.hpp.