diff --git a/.github/workflows/testing_debug_clang.yaml b/.github/workflows/testing_debug_clang.yaml index a650a44..361968e 100644 --- a/.github/workflows/testing_debug_clang.yaml +++ b/.github/workflows/testing_debug_clang.yaml @@ -27,6 +27,7 @@ jobs: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .. make -j2 - - name: run test - working-directory: ./src/build - run: ./annadb_driver +# currently broken +# - name: run test +# working-directory: ./src/build +# run: ./annadb_driver diff --git a/README.md b/README.md index 5dfd77c..ccf2920 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a C++ driver built for type-safe query creation. AnnaDB uses a custom query language called [TySON](https://github.com/roman-right/tyson) -## Requiredccccccvrcuhfhjvhckhlgnhbjurfnderebdflnkicvcr +## Required - [zeromq](https://zeromq.org/download/) - cmake >= 3.24 diff --git a/docs/html/TySON_8hpp_source.html b/docs/html/TySON_8hpp_source.html index 325b35e..5242d99 100644 --- a/docs/html/TySON_8hpp_source.html +++ b/docs/html/TySON_8hpp_source.html @@ -3,7 +3,7 @@ - + AnnaDB: src/TySON.hpp Source File @@ -29,7 +29,7 @@ - + + + + + + + + +
+
+ + + + + + +
+
AnnaDB 1.0 +
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+
Create a AnnaDB query
+
+
+

+The insert query

+
    +
  • Can only be used as a single statement
    {c++}
    +
    #include "query.hpp"
    +
    +
    // open a connection
    +
    annadb::AnnaDB con {"jondoe", "passwd1234", "localhost", 10001};
    +
    con.connect();
    +
    +
    // create a query object with the name of the collection you want to modify
    +
    auto query = annadb::Query::Query(<collection_name>);
    +
    +
    // create a TySON Object(s) you want to insert
    +
    auto new_num = tyson::TySonObject::Number(10);
    +
    +
    // pass the TySON Object(s) to the `insert` command
    +
    query.insert(new_num);
    +
    +
    // send the query
    +
    auto answer = con.send(query);
    +
  • +
  • with multiple values
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    auto query = annadb::Query::Query(<collection_name>);
    +
    +
    // create the TySON Objects
    +
    auto val_1 = tyson::TySonObject::Number(10);
    +
    auto val_2 = tyson::TySonObject::String("fizzbuzz");
    +
    auto val_3 = tyson::TySonObject::Bool(false);
    +
    +
    // pass the TySON Objects to the insert statement
    +
    query.insert(val_1, val_2, val_3);
    +
    +
    ...
    +
  • +
+

+The get query

+
    +
  • can be combined with find, get, sort, limit, offset, update, delete
  • +
  • can only be used with TySON Link Objects
  • +
  • can also be used with a std::vector or as ...T to send multiple links in one query
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    // create a TySON Link object
    +
    auto val_1 = tyson::TySonObject::Link("test", "b2279b93-00b3-4b44-9670-82a76922c0da");
    +
    +
    // use get command combined with limit
    +
    query.get(val_1).limit<short>(5);
    +
    +
    // send the query
    +
    auto answer = con.send(query);
    +
  • +
+

+The find query

+
    +
  • can be combined with find, get, sort, limit, offset
  • +
  • must be used with the Find class
  • +
  • needs to be called with any of
  • +
+ + + + + + + + + + + + + + + +
Static Version Alternative Meaning
EQ eq equals
NEQ neq not equals
GT gt greater
GTE gte greater than
LT le less
LTE lte less than
+
    +
  • multiple find statements can be combined with AND, OR, NOT
  • +
  • if you need to compare with a specific field inside of the collection pass the name of it to the constructor
      +
    • annadb::Query::Gt("num", min_num); will compare against the num field inside of the collection you could also write num.inside.a.nested.other.collection without you compare against the root node annadb::Query::Gt(min_num);
    • +
    +
  • +
+

Example Static Version from root

{c++}
+
#include "query.hpp"
+
...
+
+
// create a TySonObject object with which we want to compare
+
auto min_num = tyson::TySonObject::Number(5);
+
+
query.find(
+
// this is the static version
+
annadb::Query::Find::GT(min_num)
+
// the other comparison statements can be used in the same way
+
// annadb::Query::Find::EQ(min_num)
+
// annadb::Query::Find::NEQ(min_num)
+
// annadb::Query::Find::GTE(min_num)
+
// annadb::Query::Find::LT(min_num)
+
// annadb::Query::Find::LTE(min_num)
+
);
+
+
...
+

Example Static Version with field

{c++}
+
#include "query.hpp"
+
...
+
+
// create a TySonObject object with which we want to compare
+
auto min_num = tyson::TySonObject::Number(5);
+
+
query.find(
+
annadb::Query::Find::GT("my.field.num", min_num)
+
);
+
+
...
+

Example with instance of Find class

    +
  • this makes it easier to concat multiple finds which will not result in an And statement
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    // create a TySonObject object with which we want to compare
    +
    auto min_num = tyson::TySonObject::Number(5);
    +
    +
    // searching from the root
    +
    auto findQuery = annadb::Query::Find();
    +
    +
    // requires moving
    +
    query.find(std::move(
    +
    // can be concatenated
    +
    findQuery.gt(min_num).eq(min_num))
    +
    // if you want to compare with a specific field you can add this information
    +
    // findQuery.lt("my.num", min_num)
    +
    );
    +
    +
    ...
    +
  • +
+

Example with AND

{c++}
+
#include "query.hpp"
+
...
+
+
auto min_num = tyson::TySonObject::Number(5);
+
auto max_num = tyson::TySonObject::Number(50);
+
+
auto lower_bound = annadb::Query::Gt("num", min_num);
+
auto upper_bound = annadb::Query::Lte("num", max_num);
+
+
query.find(
+
annadb::Query::Find::AND(lower_bound, upper_bound)
+
);
+
+
...
+

Example with OR

{c++}
+
#include "query.hpp"
+
...
+
+
auto min_num = tyson::TySonObject::Number(5);
+
auto max_num = tyson::TySonObject::Number(50);
+
+
auto lower_bound = annadb::Query::Gt("num", min_num);
+
auto upper_bound = annadb::Query::Lte("num", max_num);
+
+
query.find(
+
annadb::Query::Find::OR(lower_bound, upper_bound)
+
);
+
+
...
+

Example with NOT

{c++}
+
#include "query.hpp"
+
...
+
+
query.find(
+
annadb::Query::Find::NOT("exclude.me")
+
);
+
+
...
+

+The sort query

+
    +
  • can not be used alone
  • +
  • must be used with the Sort class
  • +
  • possible choices are ASC, DESC both can be used static
  • +
  • one or more field names are required
  • +
+

single field

{c++}
+
#include "query.hpp"
+
...
+
+
auto min_num = tyson::TySonObject::Number(5);
+
+
query.find(annadb::Query::Find::GT(min_num))
+
.sort(annadb::Query::Sort::DESC("some.field"));
+
+
...
+

multiple fields

{c++}
+
#include "query.hpp"
+
...
+
+
auto min_num = tyson::TySonObject::Number(5);
+
+
query.find(annadb::Query::Find::GT(min_num))
+
.sort(annadb::Query::Sort::ASC("some", "fields", "to", "sort"));
+
+
...
+

+The limit query

+
    +
  • can not be used alone
  • +
  • needs an integral
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    auto min_num = tyson::TySonObject::Number(5);
    +
    +
    query.find(
    +
    annadb::Query::Find::GT("my.field.num", min_num).limit<short>(6)
    +
    );
    +
    +
    ...
    +
  • +
+

+The offset query

+
    +
  • can not be used alone
  • +
  • needs an integral
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    auto min_num = tyson::TySonObject::Number(5);
    +
    +
    query.find(
    +
    annadb::Query::Find::GT("my.field.num", min_num).offset<int>(260)
    +
    );
    +
    +
    ...
    +
  • +
+

+The update query

+
    +
  • can not be used alone and must be the last if you combine multiple statements
  • +
  • you can either use annadb::Query::UpdateType::Set to set a field to a specific value or annadb::Query::UpdateType::Inc to increase a field by a specific value
  • +
  • can only be used with an instance of tyson::TySonObject::Value
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    // create a TySON Link object
    +
    auto link = tyson::TySonObject::Link("test", "b2279b93-00b3-4b44-9670-82a76922c0da");
    +
    +
    // create a TySON value object
    +
    auto new_val = tyson::TySonObject::Value("num", // the name of the field
    +
    tyson::TySonObject::Number(100) // the new value
    +
    );
    +
    +
    query.get(link).update(annadb::Query::UpdateType::Set, // how you want to update
    +
    new_val // the value with which you want to update
    +
    );
    +
    +
    // use get command combined with limit
    +
    query.get(val_1).limit<short>(5);
    +
    +
    ...
    +
  • +
+

+The delete query

+
    +
  • can not be used alone and must be the last if you combine multiple statements
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    auto min_num = tyson::TySonObject::Number(5);
    +
    +
    auto query = annadb::Query::Query("test");
    +
    +
    // this query will delete all findings
    +
    query.find(annadb::Query::Find::GT(min_num)).delete_q();
    +
    +
    ...
    +
  • +
+
+
+ + + + diff --git a/docs/html/md_pages_main.html b/docs/html/md_pages_main.html index 90e81ec..75bac73 100644 --- a/docs/html/md_pages_main.html +++ b/docs/html/md_pages_main.html @@ -3,7 +3,7 @@ - + AnnaDB: AnnaDB CPP-Client @@ -29,7 +29,7 @@ - + + + + + + + + +
+
+ + + + + + +
+
AnnaDB 1.0 +
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
+
Journal Meta
+
+
+
    +
  • Each result of a transaction will be an instance of the Journal class this class has two properties Meta and Data.
  • +
  • We will now look at the Meta property
    {c++}
    +
    #include "query.hpp"
    +
    +
    annadb::AnnaDB con {"jondoe", "passwd1234", "localhost", 10001};
    +
    con.connect();
    +
    +
    auto val_1 = tyson::TySonObject::Number(10);
    +
    auto val_2 = tyson::TySonObject::String("fizzbuzz");
    +
    auto val_3 = tyson::TySonObject::Bool(false);
    +
    +
    // pass the TySON Objects to the insert statement
    +
    query.insert(val_1, val_2, val_3);
    +
    +
    // create a transaction
    +
    std::optional<Journal> answer = con.send(query);
    +
    +
    if (answer)
    +
    {
    +
    // extract the Meta information
    +
    Meta meta_information = answer.value().meta();
    +
    }
    +
    +
    con.close();
    +
  • +
+

+Extract the type of the transaction from Meta

+
    +
  • the MetaType can be any of these
      +
    • MetaType::insert_meta
    • +
    • MetaType::get_meta
    • +
    • MetaType::find_meta
    • +
    • MetaType::update_meta
    • +
    +
  • +
  • this can be used to validate that your transaction/query did what you expected
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    Meta meta_information = answer.value().meta();
    +
    +
    if (meta_information.type() == MetaType::insert_meta)
    +
    {
    +
    ...
    +
    }
    +
    ...
    +
  • +
+

+Extract the number of rows which where affected

+
    +
  • you can either use the underlying TySON Map or directly the rows count
    {c++}
    +
    #include "query.hpp"
    +
    ...
    +
    +
    Meta meta_information = answer.value().meta();
    +
    +
    // you can extract the rows count wall
    +
    // ewith an integral
    +
    short affected_rows = meta_information.rows<short>();
    +
    +
    // or you can access the underlying TySON Map
    +
    tyson::TySonObject affected_rows = meta.data();
    +
    +
    ...
    +
  • +
+
+
+ + + + diff --git a/docs/html/menudata.js b/docs/html/menudata.js index 4f92a23..8444c63 100644 --- a/docs/html/menudata.js +++ b/docs/html/menudata.js @@ -74,4 +74,5 @@ var menudata={children:[ {text:"u",url:"functions_func.html#index_u"}, {text:"v",url:"functions_func.html#index_v"}]}]}]}, {text:"Files",url:"files.html",children:[ -{text:"File List",url:"files.html"}]}]} +{text:"File List",url:"files.html"}]}, +{text:"Examples",url:"examples.html"}]} diff --git a/docs/html/namespaceannadb_1_1Query.html b/docs/html/namespaceannadb_1_1Query.html index 30fcba2..e58ce67 100644 --- a/docs/html/namespaceannadb_1_1Query.html +++ b/docs/html/namespaceannadb_1_1Query.html @@ -3,7 +3,7 @@ - + AnnaDB: annadb::Query Namespace Reference @@ -29,7 +29,7 @@ - +