Represents a collection of documents in the database.
More...
#include <docudb.hpp>
Represents a collection of documents in the database.
Definition at line 744 of file docudb.hpp.
◆ db_collection() [1/4]
docudb::db_collection::db_collection |
( |
| ) |
|
|
default |
◆ db_collection() [2/4]
◆ db_collection() [3/4]
◆ db_collection() [4/4]
docudb::db_collection::db_collection |
( |
std::string_view | name, |
|
|
sqlite3 * | db_handle ) |
Constructs a new db_collection object.
- Parameters
-
name | The name of the collection. |
db_handle | The SQLite database handle. |
◆ count() [1/2]
std::size_t docudb::db_collection::count |
( |
| ) |
const |
Gets the number of documents in the collection.
- Returns
- std::size_t The number of documents in the collection.
◆ count() [2/2]
Gets the number of documents that matches the given query.
- Parameters
-
- Returns
- std::size_t The number of matching documents.
◆ create()
db_document docudb::db_collection::create |
( |
std::string_view | doc_id | ) |
|
Creates a new document with the given ID.
- Returns
- db_document The new document object.
◆ doc() [1/2]
Creates a new document with a generated UUID.
- Returns
- db_document The new document object.
◆ doc() [2/2]
db_document docudb::db_collection::doc |
( |
std::string_view | doc_id | ) |
const |
Gets a document by ID.
- Parameters
-
- Returns
- db_document The document object.
◆ docs()
Gets all documents in the collection.
- Returns
- std::vector<db_document_ref> The list of document references.
◆ find()
Searches documents by query.
- Parameters
-
q | The query object. |
order_by | The order by object (optional) |
limit | The maximum number of documents to return (optional). |
- Returns
- std::vector<db_document_ref> The list of document references.
◆ index() [1/2]
db_collection & docudb::db_collection::index |
( |
std::string | name, |
|
|
std::vector< std::pair< std::string, std::string > > const & | columns, |
|
|
bool | unique ) |
Indexes the document based on the specified columns and query.
This function creates a new virtual column representing the given json query and add an index to that column.
- Parameters
-
name | The index name |
columns | A vector of pairs [column_name, query] |
unique | The index should be unique |
- Returns
- A reference to the document.
◆ index() [2/2]
db_collection & docudb::db_collection::index |
( |
std::string_view | column_name, |
|
|
std::string_view | query, |
|
|
bool | unique = false ) |
Indexes the document based on the specified column and query.
This function creates a new virtual column representing the given json query and add an index to that column.
- Parameters
-
column_name | The name of the column to be created. |
query | The json query string in SQLite format representing the field to be indexed |
unique | The index should be unique |
- Returns
- A reference to the document.
◆ name()
std::string docudb::db_collection::name |
( |
| ) |
const |
|
noexcept |
Gets the collection name.
- Returns
- std::string The collection name.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ remove()
void docudb::db_collection::remove |
( |
std::string_view | doc_id | ) |
|
Removes a document by ID.
- Parameters
-
The documentation for this struct was generated from the following file: