Skip to content

Commit

Permalink
feat(neo4j): set priority to overrided roles in organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-jeannoutot committed Apr 21, 2022
1 parent 6e55cf0 commit dfac1c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions neo4j/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func (r *UserRepository) FetchUserOrganizations(ctx context.Context, userID stri
defer session.Close()

res, err := session.Run(`
match (u:User {user_id: $user_id})-[ruo:WORKS_AT|BUY_FOR|MANAGE|OWN|DEALS_WITH]->(o:Organization)
return o.organization_id as organization_id, type(ruo) as role
union all
match (u:User {user_id: $user_id})-[ruh:WORKS_AT|BUY_FOR|MANAGE|OWN]->(h:Organization)-[rhn:HEAD_OF]->(n:Network)<-[ron:IN]-(o:Organization)
return o.organization_id as organization_id, 'WORKS_AT' as role
union all
union all
match (u:User {user_id: $user_id})-[ruh:DEALS_WITH]->(h:Organization)-[rhn:HEAD_OF]->(n:Network)<-[ron:IN]-(o:Organization)
return o.organization_id as organization_id, 'DEALS_WITH' as role
union all
match (u:User {user_id: $user_id})-[ruo:WORKS_AT|BUY_FOR|MANAGE|OWN|DEALS_WITH]->(o:Organization)
return o.organization_id as organization_id, type(ruo) as role
`, map[string]interface{}{
"user_id": userID,
})
Expand Down

0 comments on commit dfac1c7

Please sign in to comment.