docudb  1.0
Loading...
Searching...
No Matches
docudb::db_document Struct Reference

Represents a database document. More...

#include <docudb.hpp>

Public Member Functions

std::string id () const
 Gets the document ID.
 
std::string body () const
 Gets the full body of the document.
 
db_documentbody (std::string_view body)
 Sets the full body of the document.
 
db_documentreplace (std::string_view query, std::float_t value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::double_t value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::int32_t value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::int64_t value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::nullptr_t value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::string const &value)
 Replace a value in the json body.
 
db_documentreplace (std::string_view query, std::string_view value)
 Replace a value in the json body.
 
db_documentset (std::string_view query, std::float_t value)
 
db_documentset (std::string_view query, std::double_t value)
 
db_documentset (std::string_view query, std::int32_t value)
 
db_documentset (std::string_view query, std::int64_t value)
 
db_documentset (std::string_view query, std::nullptr_t value)
 
db_documentset (std::string_view query, std::string const &value)
 
db_documentset (std::string_view query, std::string_view value)
 
db_documentinsert (std::string_view query, std::float_t value)
 
db_documentinsert (std::string_view query, std::double_t value)
 
db_documentinsert (std::string_view query, std::int32_t value)
 
db_documentinsert (std::string_view query, std::int64_t value)
 
db_documentinsert (std::string_view query, std::nullptr_t value)
 
db_documentinsert (std::string_view query, std::string const &value)
 
db_documentinsert (std::string_view query, std::string_view value)
 
db_documentpatch (std::string_view json)
 Patches the JSON body of the document.
 
std::string get_string (std::string_view query) const
 
std::int64_t get_number (std::string_view query) const
 
std::double_t get_real (std::string_view query) const
 
json_type get_type (std::string_view query) const
 
std::size_t get_array_length (std::string_view query) const
 
std::vector< std::string > get_object_keys (std::string_view query) const
 
template<typename... Types>
std::tuple< Types... > get (const std::vector< std::string > &fields) const
 
void erase ()
 Removes the document from the collection.
 

Friends

struct db_collection
 
struct db_document_ref
 

Detailed Description

Represents a database document.

Definition at line 562 of file docudb.hpp.

Member Function Documentation

◆ body() [1/2]

std::string docudb::db_document::body ( ) const

Gets the full body of the document.

Returns
std::string The document body.

◆ body() [2/2]

db_document & docudb::db_document::body ( std::string_view body)

Sets the full body of the document.

Parameters
bodyThe new body content.
Returns
db_document& Reference to the document.

◆ erase()

void docudb::db_document::erase ( )

Removes the document from the collection.

Returns
void

◆ get()

template<typename... Types>
std::tuple< Types... > docudb::db_document::get ( const std::vector< std::string > & fields) const
inline

Definition at line 695 of file docudb.hpp.

695 {
696 if (fields.size() != sizeof...(Types)) {
697 throw std::invalid_argument("Number of fields does not match the number of types.");
698 }
699
700 auto stmt = get_value_stmt_impl(fields);
701 auto ret = get_values_impl<Types...>(stmt, std::index_sequence_for<Types...>{});
702
703 return ret;
704 }

◆ get_array_length()

std::size_t docudb::db_document::get_array_length ( std::string_view query) const

◆ get_number()

std::int64_t docudb::db_document::get_number ( std::string_view query) const

◆ get_object_keys()

std::vector< std::string > docudb::db_document::get_object_keys ( std::string_view query) const

◆ get_real()

std::double_t docudb::db_document::get_real ( std::string_view query) const

◆ get_string()

std::string docudb::db_document::get_string ( std::string_view query) const

◆ get_type()

json_type docudb::db_document::get_type ( std::string_view query) const

◆ id()

std::string docudb::db_document::id ( ) const

Gets the document ID.

Returns
std::string The document ID.

◆ insert() [1/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::double_t value )

◆ insert() [2/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::float_t value )

◆ insert() [3/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::int32_t value )

◆ insert() [4/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::int64_t value )

◆ insert() [5/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::nullptr_t value )

◆ insert() [6/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::string const & value )

◆ insert() [7/7]

db_document & docudb::db_document::insert ( std::string_view query,
std::string_view value )

◆ patch()

db_document & docudb::db_document::patch ( std::string_view json)

Patches the JSON body of the document.

Parameters
jsonThe JSON patch.
Returns
db_document& Reference to the document.

◆ replace() [1/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::double_t value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [2/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::float_t value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [3/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::int32_t value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [4/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::int64_t value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [5/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::nullptr_t value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [6/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::string const & value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ replace() [7/7]

db_document & docudb::db_document::replace ( std::string_view query,
std::string_view value )

Replace a value in the json body.

Parameters
queryThe query that points to the value to replace.
valueThe new value
Returns
db_document& Reference to the document.

◆ set() [1/7]

db_document & docudb::db_document::set ( std::string_view query,
std::double_t value )

◆ set() [2/7]

db_document & docudb::db_document::set ( std::string_view query,
std::float_t value )

◆ set() [3/7]

db_document & docudb::db_document::set ( std::string_view query,
std::int32_t value )

◆ set() [4/7]

db_document & docudb::db_document::set ( std::string_view query,
std::int64_t value )

◆ set() [5/7]

db_document & docudb::db_document::set ( std::string_view query,
std::nullptr_t value )

◆ set() [6/7]

db_document & docudb::db_document::set ( std::string_view query,
std::string const & value )

◆ set() [7/7]

db_document & docudb::db_document::set ( std::string_view query,
std::string_view value )

Friends And Related Symbol Documentation

◆ db_collection

friend struct db_collection
friend

Definition at line 726 of file docudb.hpp.

◆ db_document_ref

friend struct db_document_ref
friend

Definition at line 727 of file docudb.hpp.


The documentation for this struct was generated from the following file: