Empty relationship resource was added and Graph object knows how to find a vertex
This commit is contained in:
parent
26b426e1fa
commit
7564c35d19
@ -70,23 +70,8 @@ public:
|
|||||||
task->run([this, &req]() -> Vertex* {
|
task->run([this, &req]() -> Vertex* {
|
||||||
// read id param
|
// read id param
|
||||||
uint64_t id = std::stoull(req.params[0]);
|
uint64_t id = std::stoull(req.params[0]);
|
||||||
|
// TODO: transaction?
|
||||||
// get atom iterator
|
return db->graph.find_vertex(id);
|
||||||
auto atom_it = db->graph.vertices.begin();
|
|
||||||
|
|
||||||
// find the right atom
|
|
||||||
// TODO: better implementation
|
|
||||||
while (true) {
|
|
||||||
if (id == atom_it->id) {
|
|
||||||
// TODO: return latest version
|
|
||||||
return atom_it->first();
|
|
||||||
}
|
|
||||||
if (!atom_it.has_next())
|
|
||||||
break;
|
|
||||||
++atom_it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
},
|
},
|
||||||
[&req, &res](Vertex* node) {
|
[&req, &res](Vertex* node) {
|
||||||
if (node == nullptr) {
|
if (node == nullptr) {
|
||||||
|
31
api/resources/relationship.hpp
Normal file
31
api/resources/relationship.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef MEMGRAPH_API_RESOURCES_RELATIONSHIP_HPP
|
||||||
|
#define MEMGRAPH_API_RESOURCES_RELATIONSHIP_HPP
|
||||||
|
|
||||||
|
#include "api/restful/resource.hpp"
|
||||||
|
|
||||||
|
#pragma url /relationship
|
||||||
|
class Relationships : public Resource<Relationships, POST>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Resource::Resource;
|
||||||
|
|
||||||
|
void post(sp::Request& req, sp::Response& res)
|
||||||
|
{
|
||||||
|
return res.send("POST /db/data/relationship");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma url /relationship/{id:\\d+}
|
||||||
|
class Relationship : public Resource<Relationship, GET>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Resource::Resource;
|
||||||
|
|
||||||
|
void get(sp::Request& req, sp::Response& res)
|
||||||
|
{
|
||||||
|
return res.send("GET /db/data/relationship");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -38,6 +38,27 @@ public:
|
|||||||
return edges.insert(t);
|
return edges.insert(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: this should probably return mvcc::Atom<Vertex>*
|
||||||
|
Vertex* find_vertex(uint64_t id)
|
||||||
|
{
|
||||||
|
// get atom iterator
|
||||||
|
auto atom_it = vertices.begin();
|
||||||
|
|
||||||
|
// find the right atom
|
||||||
|
// TODO: better implementation
|
||||||
|
while (true) {
|
||||||
|
if (id == atom_it->id) {
|
||||||
|
// TODO: return latest version
|
||||||
|
return atom_it->first();
|
||||||
|
}
|
||||||
|
if (!atom_it.has_next())
|
||||||
|
break;
|
||||||
|
++atom_it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
VertexStore vertices;
|
VertexStore vertices;
|
||||||
EdgeStore edges;
|
EdgeStore edges;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user