diff --git a/api/resources/node.hpp b/api/resources/node.hpp index f717c8462..c4db74ca1 100644 --- a/api/resources/node.hpp +++ b/api/resources/node.hpp @@ -2,17 +2,17 @@ #include -#include "api/restful/resource.hpp" -#include "mvcc/version_list.hpp" #include "debug/log.hpp" +#include "mvcc/version_list.hpp" #include "api/response_json.hpp" +#include "api/restful/resource.hpp" #pragma url /node class Nodes : public Resource { public: using Resource::Resource; - + void post(sp::Request& req, sp::Response& res) { task->run([this, &req]() { @@ -22,12 +22,12 @@ public: // insert a new vertex auto vertex_proxy = db->graph.vertices.insert(transaction); - // map fields - for(auto it = req.json.MemberBegin(); it != req.json.MemberEnd(); ++it) + auto begin_it = req.json.MemberBegin(); + auto end_it = req.json.MemberEnd(); + for(auto it = begin_it; it != end_it; ++it) { - vertex_proxy.property( - it->name.GetString(), - it->value.GetString() + vertex_proxy.property( + it->name.GetString(), it->value.GetString() ); } @@ -37,7 +37,10 @@ public: return std::move(vertex_proxy); }, [&req, &res](VertexProxy&& vertex_proxy) { - return res.send(http::Status::Created, vertex_create_response(vertex_proxy)); + return res.send( + http::Status::Created, + vertex_create_response(vertex_proxy) + ); }); } }; diff --git a/storage/vertices.hpp b/storage/vertices.hpp index fc8943df2..c4b862259 100644 --- a/storage/vertices.hpp +++ b/storage/vertices.hpp @@ -20,6 +20,9 @@ public: auto vertex_accessor = vertex_record->second.access(transaction); auto vertex = vertex_accessor.find(); + // TODO: here is problem to create vertex_proxy because vertex + // is const pointer + return vertex; } @@ -41,7 +44,6 @@ public: auto vertex = vertex_accessor.insert(); VertexProxy vertex_proxy(next, vertex, this, &inserted_vertex_record->second); - return vertex_proxy; }