Add remove label to the query modules C API (#1126)

This commit is contained in:
ind1xa 2023-08-01 19:24:11 +02:00 committed by GitHub
parent e8850549d2
commit 50a1d1abb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -389,6 +389,10 @@ inline bool vertex_has_label_named(mgp_vertex *v, const char *label_name) {
inline void vertex_add_label(mgp_vertex *vertex, mgp_label label) { MgInvokeVoid(mgp_vertex_add_label, vertex, label); }
inline void vertex_remove_label(mgp_vertex *vertex, mgp_label label) {
MgInvokeVoid(mgp_vertex_remove_label, vertex, label);
}
inline mgp_value *vertex_get_property(mgp_vertex *v, const char *property_name, mgp_memory *memory) {
return MgInvoke<mgp_value *>(mgp_vertex_get_property, v, property_name, memory);
}

View File

@ -610,6 +610,7 @@ class Node {
/// @brief Creates a Node from the copy of the given @ref mgp_vertex.
explicit Node(mgp_vertex *ptr);
/// @brief Creates a Node from the copy of the given @ref mgp_vertex.
explicit Node(const mgp_vertex *const_ptr);
@ -641,15 +642,21 @@ class Node {
/// @brief Returns an iterable structure of the nodes inbound relationships.
Relationships InRelationships() const;
/// @brief Returns an iterable structure of the nodes outbound relationships.
Relationships OutRelationships() const;
/// @brief Adds a label to the node.
void AddLabel(const std::string_view label);
/// @brief Removes a label from the node.
void RemoveLabel(const std::string_view label);
bool operator<(const Node &other) const;
/// @exception std::runtime_error Node properties contain value(s) of unknown type.
bool operator==(const Node &other) const;
/// @exception std::runtime_error Node properties contain value(s) of unknown type.
bool operator!=(const Node &other) const;
@ -2546,6 +2553,10 @@ inline void Node::AddLabel(const std::string_view label) {
mgp::vertex_add_label(this->ptr_, mgp_label{.name = label.data()});
}
inline void Node::RemoveLabel(const std::string_view label) {
mgp::vertex_remove_label(this->ptr_, mgp_label{.name = label.data()});
}
inline std::map<std::string, Value> Node::Properties() const {
mgp_properties_iterator *properties_iterator = mgp::vertex_iter_properties(ptr_, memory);
std::map<std::string, Value> property_map;