ejpp
Embedded JSON Database engine for C++11/14
|
View on GitHub
Main point of access to EJDB. More...
#include <ejdb.hpp>
Public Member Functions | |
db () noexcept=default | |
Default constructor. Result is a null EJDB handle. | |
bool | close (std::error_code &ec) noexcept |
Closes the currently open EJDB database. More... | |
void | close () |
Closes the currently open EJDB database. More... | |
collection | create_collection (const std::string &name, std::error_code &ec) |
Returns an existing, or otherwise newly created, collection, named name . More... | |
collection | create_collection (const std::string &name) |
Returns an existing, or otherwise newly created, collection, named name . More... | |
query | create_query (const std::vector< char > &doc, std::error_code &ec) |
Create a query from a BSON document. More... | |
query | create_query (const std::vector< char > &doc) |
Create a query from a BSON document. More... | |
std::error_code | error () const noexcept |
Returns last error that occurred. More... | |
collection | get_collection (const std::string &name, std::error_code &ec) const |
Returns an existing collection named name , or a default constructed ejdb::collection. More... | |
collection | get_collection (const std::string &name) const |
Returns an existing collection named name , or a default constructed ejdb::collection. More... | |
const std::vector< collection > | get_collections () const |
Returns all existing collections. | |
bool | is_open () const noexcept |
Returns whether the db object refers to a valid and open EJDB database. | |
std::vector< char > | metadata (std::error_code &ec) |
Returns description of the EJDB database. More... | |
std::vector< char > | metadata () |
Returns description of the EJDB database. More... | |
bool | open (const std::string &path, db_mode mode, std::error_code &ec) |
Opens EJDB database at path . More... | |
void | open (const std::string &path, db_mode mode) |
Opens EJDB database at path . More... | |
operator bool () const noexcept | |
Returns whether a valid EJDB handle is contained within. | |
bool | remove_collection (const std::string &name, bool unlink_file, std::error_code &ec) |
Removes a collection named name , or do nothing if name does not exist. More... | |
void | remove_collection (const std::string &name, bool unlink_file) |
Removes a collection named name , or do nothing if name does not exist. More... | |
bool | sync (std::error_code &ec) noexcept |
Synchronise the EJDB database to disk. More... | |
void | sync () |
Synchronise the EJDB database to disk. More... | |
Static Public Member Functions | |
static std::error_code | error (std::weak_ptr< EJDB >) noexcept |
Returns last error that occurred. More... | |
Main point of access to EJDB.
Uses a shared implementation, i.e. copies of a db object operate on the same EJDB handle.
|
noexcept |
Closes the currently open EJDB database.
[out] | ec | Set to an appropriate error code on failure. |
void ejdb::db::close | ( | ) |
Closes the currently open EJDB database.
std::system_error | with appropriate error code and message on failure. |
collection ejdb::db::create_collection | ( | const std::string & | name, |
std::error_code & | ec | ||
) |
Returns an existing, or otherwise newly created, collection, named name
.
name | Name of collection to fetch or create. | |
[out] | ec | Set to an appropriate error code on failure. |
collection ejdb::db::create_collection | ( | const std::string & | name | ) |
Returns an existing, or otherwise newly created, collection, named name
.
name | Name of collection to fetch or create. |
std::system_error | with appropriate error code and message on failure. |
query ejdb::db::create_query | ( | const std::vector< char > & | doc, |
std::error_code & | ec | ||
) |
Create a query from a BSON document.
EJDB's query documentation follows.
EJDB queries inspired by MongoDB (mongodb.org) and follows same philosophy.
JBIDXISTR
doc | BSON query object. | |
[out] | ec | Set to an appropriate error code on failure. |
query ejdb::db::create_query | ( | const std::vector< char > & | doc | ) |
Create a query from a BSON document.
Same as create_query, throws exception instead of setting an std::error_code on failure.
doc | BSON query object. |
std::system_error | with appropriate error code and message on failure. |
|
noexcept |
Returns last error that occurred.
|
staticnoexcept |
Returns last error that occurred.
db | weak_ptr to an EJDB handle. |
collection ejdb::db::get_collection | ( | const std::string & | name, |
std::error_code & | ec | ||
) | const |
Returns an existing collection named name
, or a default constructed ejdb::collection.
name | Name of collection to fetch. | |
[out] | ec | Set to an appropriate error code on failure. |
collection ejdb::db::get_collection | ( | const std::string & | name | ) | const |
Returns an existing collection named name
, or a default constructed ejdb::collection.
name | Name of collection to fetch. |
name
found, throws on failure.std::system_error | with appropriate error code and message on failure. |
std::vector< char > ejdb::db::metadata | ( | std::error_code & | ec | ) |
Returns description of the EJDB database.
[out] | ec | Set to an appropriate error code on failure. |
std::vector< char > ejdb::db::metadata | ( | ) |
Returns description of the EJDB database.
std::system_error | with appropriate error code and message on failure. |
bool ejdb::db::open | ( | const std::string & | path, |
db_mode | mode, | ||
std::error_code & | ec | ||
) |
Opens EJDB database at path
.
path | Location on filesystem where an EJDB databaes exists. | |
mode | Bitwise-ORed flags to determine how to open the database. | |
[out] | ec | Set to an appropriate error code on failure. |
void ejdb::db::open | ( | const std::string & | path, |
db_mode | mode | ||
) |
Opens EJDB database at path
.
path | Location on filesystem where an EJDB databaes exists. |
mode | Bitwise-ORed flags to determine how to open the database. |
std::system_error | with appropriate error code and message on failure. |
bool ejdb::db::remove_collection | ( | const std::string & | name, |
bool | unlink_file, | ||
std::error_code & | ec | ||
) |
Removes a collection named name
, or do nothing if name
does not exist.
name | Name of collection to remove. | |
unlink_file | Whether to remove associated files, i.e. db collection file, indexes, etc. | |
[out] | ec | Set to an appropriate error code on failure. |
void ejdb::db::remove_collection | ( | const std::string & | name, |
bool | unlink_file | ||
) |
Removes a collection named name
, or do nothing if name
does not exist.
name | Name of collection to remove. |
unlink_file | Whether to remove associated files, i.e. db collection file, indexes, etc. |
std::system_error | with appropriate error code and message on failure. |
|
noexcept |
Synchronise the EJDB database to disk.
[out] | ec | Set to an appropriate error code on failure. |
void ejdb::db::sync | ( | ) |
Synchronise the EJDB database to disk.
std::system_error | with appropriate error code and message on failure. |