diff --git a/app/repositories/orient_db/institution_repository.rb b/app/repositories/orient_db/institution_repository.rb index 60769dd996d24127106d1569707f48a1631b507c..4fbcfbf573fbeb87b619349a362fcfb65047703f 100644 --- a/app/repositories/orient_db/institution_repository.rb +++ b/app/repositories/orient_db/institution_repository.rb @@ -27,12 +27,17 @@ module OrientDb end 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 end 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 def build_object(args={})