aboutsummaryrefslogtreecommitdiff
path: root/db/uobject.cpp
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-08-08 15:50:31 +0200
committerneodarz <neodarz@neodarz.net>2019-08-08 15:50:31 +0200
commit0ce9ff7103a8303cbf7bbefe22adbc2b9505ea17 (patch)
treee924b3f1d325fe961f19a62f1aeaf038eaa3a4ef /db/uobject.cpp
parentdb5f789c5aeaee55ee0b54cb251eb5e5fbc0ec5b (diff)
downloadumosapicpp-0ce9ff7103a8303cbf7bbefe22adbc2b9505ea17.tar.xz
umosapicpp-0ce9ff7103a8303cbf7bbefe22adbc2b9505ea17.zip
Split some codes
Diffstat (limited to 'db/uobject.cpp')
-rw-r--r--db/uobject.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/db/uobject.cpp b/db/uobject.cpp
new file mode 100644
index 0000000..769631e
--- /dev/null
+++ b/db/uobject.cpp
@@ -0,0 +1,16 @@
+#include "uobject.h"
+
+std::string uobject::retrieveAll(std::string collection, struct json_object* jsonObjects) {
+
+ auto conn = mongo.get_connection();
+
+ auto coll = (*conn)[config["mongo_db"]][collection];
+
+ auto cursor = coll.find({});
+
+ for (auto&& doc : cursor) {
+ json_object_array_add(jsonObjects, json_tokener_parse(bsoncxx::to_json(doc).c_str()));
+ }
+
+ return json_object_to_json_string_ext(jsonObjects, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+}