-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEJDB.h
75 lines (53 loc) · 1.78 KB
/
EJDB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef EJDB_CPP_H
#define EJDB_CPP_H
#include <string>
#include <ejdb2/ejdb2.h>
#include <result.hpp>
#include "EJDBQuery.h"
#include <functional>
class EJDBPP
{
private:
EJDB m_db;
public:
EJDBPP();
enum class EJDBError
{
None = 0,
Success = 0,
FailedToInit,
FailedToOpen,
FailedToClose,
JSONParsingError,
FailedToPut,
FailedToExec,
FailedToOnlineBackUp,
FailedToRemoveCollection,
FailedToRemoveIndex,
FailedToEnsureIndex,
FailedToRenameCollection,
FailedToDel,
FailedToGetInfo,
FailedToConvertJSONToString,
FailedToGet,
NotFound,
FailedToPatch
};
static EJDBError init();
EJDBError open(const EJDB_OPTS &opts);
EJDBPP::EJDBError close();
cpp::result<int64_t, EJDBError> putNew(const std::string &collection, const std::string &json);
EJDBPP::EJDBError put(const std::string &collection, const std::string &json, uint64_t id);
EJDBPP::EJDBError patch(const std::string &collection, const std::string &json, uint64_t id);
cpp::result<std::string, EJDBPP::EJDBError> get(const std::string &collection, uint64_t id);
cpp::result<std::string, EJDBError> info();
EJDBError del(const std::string &collection, int64_t id);
EJDBError renameCollection(const std::string &oldCollectionName, const std::string &newCollectionName);
EJDBError ensureIndex(const std::string &collection, const std::string &path, ejdb_idx_mode_t unique);
EJDBError removeIndex(const std::string &collection, const std::string &path, ejdb_idx_mode_t mode);
EJDBError removeCollection(const std::string &collection);
cpp::result<uint64_t, EJDBError> onlineBackup(const std::string &fileName);
EJDBError exec(const EJDBQuery &q, std::function<iwrc(EJDB_EXEC *, const EJDB_DOC, int64_t *)> callback);
~EJDBPP();
};
#endif