forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove-edges.js
More file actions
42 lines (39 loc) · 858 Bytes
/
Copy pathremove-edges.js
File metadata and controls
42 lines (39 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const removeEdges = async ({
db,
direction,
vertexSelectorId,
edgeCollection,
removeVertices = false,
vertexCollection,
}) => {
// remove vertices
if (removeVertices) {
console.log('vertexCollection: ', vertexCollection)
const params = { vertexSelectorId, edgeCollection }
await (
await db.query(
`
FOR v, e IN 1..1 ${direction} @vertexSelectorId @edgeCollection
REMOVE e IN ${edgeCollection}
REMOVE v IN ${vertexCollection}
`,
params,
)
).all()
return
}
// don't remove vertices
const params = { vertexSelectorId, edgeCollection }
await (
await db.query(
`
FOR v, e IN 1..1 ${direction} @vertexSelectorId @edgeCollection
REMOVE e IN ${edgeCollection}
`,
params,
)
).all()
}
module.exports = {
removeEdges,
}