Skip to content
Snippets Groups Projects
Commit e2d79a03 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

verify if user relationship exists before add or remove

parent f60b2b8b
No related branches found
No related tags found
No related merge requests found
...@@ -27,12 +27,17 @@ module OrientDb ...@@ -27,12 +27,17 @@ module OrientDb
end end
def add_user(user, institution) def add_user(user, institution)
create_edge "BelongsTo", user.rid, institution.id unless edge_exists? "BelongsTo", user.rid, institution.id
create_edge "BelongsTo", user.rid, institution.id
end
institution institution
end end
def remove_user(user, institution) def remove_user(user, institution)
destroy_edge "BelongsTo", user.rid, institution.id if edge_exists? "BelongsTo", user.rid, institution.id
destroy_edge "BelongsTo", user.rid, institution.id
end
end end
def build_object(args={}) def build_object(args={})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment