7 #include <SimoxUtility/json.h>
12 #include <mongocxx/client.hpp>
13 #include <mongocxx/instance.hpp>
14 #include <mongocxx/pool.hpp>
15 #include <mongocxx/stdx.hpp>
16 #include <mongocxx/uri.hpp>
17 #include <bsoncxx/builder/stream/array.hpp>
18 #include <bsoncxx/builder/stream/document.hpp>
19 #include <bsoncxx/builder/stream/helpers.hpp>
20 #include <bsoncxx/json.hpp>
27 inline const std::map<std::string, std::string>
EscapeTable = {{
"/",
"|"}};
29 std::string
escapeName(
const std::string& segmentName);
31 std::string
unescapeName(
const std::string& escapedName);
33 bool insert(mongocxx::collection& coll,
const nlohmann::json&
value);
35 std::optional<nlohmann::json>
contains(mongocxx::collection& coll,
36 const nlohmann::json&
value);
38 bool update(mongocxx::collection& coll,
39 const nlohmann::json& query,
40 const std::string& vkey,
41 const nlohmann::json& vdata);
47 std::optional<mongocxx::database>
databaseExists(mongocxx::client&,
48 const std::string& databaseName);
50 const std::string& databaseName,
51 bool createIfNotExistent);
54 const std::string& collectionName);
56 const std::string& collectionName,
57 bool createIfNotExistent);
59 std::optional<nlohmann::json>
documentExists(mongocxx::collection& collection,
60 const nlohmann::json& query);
63 const nlohmann::json& query,
64 bool createIfNotExistent =
false);
67 const nlohmann::json& query);
70 const nlohmann::json& query,
71 const nlohmann::json&
data);
73 std::vector<nlohmann::json>
getAllDocuments(mongocxx::collection& collection);