Skip to content

Commit 5f8a184

Browse files
committed
Replace a setLabels as an example
1 parent fdbbf0c commit 5f8a184

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/components/file/media/media.repository.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ export class MediaRepository extends CommonRepository {
114114
// Update the labels if typename is given, and maybe changed.
115115
.apply((q) =>
116116
res
117-
? q.raw(
118-
'CALL apoc.create.setLabels(node, $newLabels) yield node as labelsAdded',
119-
{ newLabels: res.dbLabels },
120-
)
117+
? q
118+
.call(apoc.create.setLabels('node', res.dbLabels))
119+
.yield('node as labelsAdded')
121120
: q,
122121
)
123122
// Grab the previous media node or null

src/core/database/query/cypher-functions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export const apoc = {
7676
/** Converts Neo4j node to object/map of the node's properties */
7777
toMap: fn1('apoc.convert.toMap'),
7878
},
79+
create: {
80+
setLabels: (node: ExpressionInput, labels: readonly string[]) => ({
81+
name: 'apoc.create.setLabels',
82+
args: { node: exp(node), labels },
83+
}),
84+
},
7985
};
8086

8187
/**

0 commit comments

Comments
 (0)