@@ -66,7 +66,8 @@ func (r *RoleRepository) Create(ctx context.Context, createdBy, belongsTo model.
6666 role .UpdatedAt = nil
6767
6868 cypher := `
69- MATCH (u:` + createdBy .Label () + ` {id: $owner_id}), (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
69+ MATCH (u:` + createdBy .Label () + ` {id: $owner_id})
70+ MATCH (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
7071 MERGE (r:` + role .ID .Label () + ` {id: $role_id})
7172 ON CREATE SET r += { name: $name, description: $description, created_at: datetime($created_at) }
7273 CREATE (r)<-[:` + EdgeKindHasTeam .String () + ` { id: $has_team_id, created_at: datetime($created_at) }]-(b)
@@ -99,7 +100,8 @@ func (r *RoleRepository) Get(ctx context.Context, id, belongsTo model.ID) (*mode
99100 defer span .End ()
100101
101102 cypher := `
102- MATCH (r:` + id .Label () + ` {id: $id}), (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
103+ MATCH (r:` + id .Label () + ` {id: $id})
104+ MATCH (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
103105 OPTIONAL MATCH (r)<-[:` + EdgeKindMemberOf .String () + `]-(u:` + model .ResourceTypeUser .String () + `)
104106 OPTIONAL MATCH (r)-[p:` + EdgeKindHasPermission .String () + `]->()
105107 RETURN r, collect(DISTINCT u.id) AS m, collect(DISTINCT p.id) AS p
@@ -153,7 +155,8 @@ func (r *RoleRepository) Update(ctx context.Context, id, belongsTo model.ID, pat
153155 defer span .End ()
154156
155157 cypher := `
156- MATCH (r:` + id .Label () + ` {id: $id}), (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
158+ MATCH (r:` + id .Label () + ` {id: $id})
159+ MATCH (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
157160 SET r += $patch, r.updated_at = datetime()
158161 WITH r
159162 OPTIONAL MATCH (r)<-[:` + EdgeKindMemberOf .String () + `]-(u:` + model .ResourceTypeUser .String () + `)
@@ -179,7 +182,9 @@ func (r *RoleRepository) AddMember(ctx context.Context, roleID, memberID, belong
179182 defer span .End ()
180183
181184 cypher := `
182- MATCH (r:` + roleID .Label () + ` {id: $role_id}), (u:` + memberID .Label () + ` {id: $member_id}), (b:` + belongsToID .Label () + ` {id: $belongs_to_id})
185+ MATCH (r:` + roleID .Label () + ` {id: $role_id})
186+ MATCH (u:` + memberID .Label () + ` {id: $member_id})
187+ MATCH (b:` + belongsToID .Label () + ` {id: $belongs_to_id})
183188 MERGE (u)-[m:` + EdgeKindMemberOf .String () + `]->(r)
184189 ON CREATE SET m.created_at = datetime($now), m.id = $membership_id
185190 ON MATCH SET m.updated_at = datetime($now)`
@@ -204,7 +209,8 @@ func (r *RoleRepository) RemoveMember(ctx context.Context, roleID, memberID, bel
204209 defer span .End ()
205210
206211 cypher := `
207- MATCH (:` + roleID .Label () + ` {id: $role_id})<-[r:` + EdgeKindMemberOf .String () + `]-(:` + memberID .Label () + ` {id: $member_id}), (b:` + belongsToID .Label () + ` {id: $belongs_to_id})
212+ MATCH (:` + roleID .Label () + ` {id: $role_id})<-[r:` + EdgeKindMemberOf .String () + `]-(:` + memberID .Label () + ` {id: $member_id})
213+ MATCH (b:` + belongsToID .Label () + ` {id: $belongs_to_id})
208214 DELETE r`
209215
210216 params := map [string ]any {
@@ -224,7 +230,9 @@ func (r *RoleRepository) Delete(ctx context.Context, id, belongsTo model.ID) err
224230 ctx , span := r .tracer .Start (ctx , "repository.neo4j.RoleRepository/Delete" )
225231 defer span .End ()
226232
227- cypher := `MATCH (r:` + id .Label () + ` {id: $id}), (b:` + belongsTo .Label () + ` {id: $belongs_to_id}) DETACH DELETE r`
233+ cypher := `MATCH (r:` + id .Label () + ` {id: $id})
234+ MATCH (b:` + belongsTo .Label () + ` {id: $belongs_to_id})
235+ DETACH DELETE r`
228236 params := map [string ]any {
229237 "id" : id .String (),
230238 "belongs_to_id" : belongsTo .String (),
0 commit comments