Skip to content

Commit

Permalink
feat: add aql query for loading only new relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersiddhu committed Oct 22, 2018
1 parent 8a34da9 commit 7fbf324
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions storage/arangodb/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ const (
COLLECT WITH COUNT INTO c
RETURN c
`
rinst = `
FOR c IN %s
FOR cvt IN %s
FILTER c.id == %s
FILTER c._id == cvt.graph_id
LET nch = MINUS (
FOR v IN 1..1 OUTBOUND cvt %s
OPTIONS { bfs: true, uniqueVertices: 'global' }
RETURN v.id,
FOR v IN 1..1 OUTBOUND cvt GRAPH %s
OPTIONS { bfs: true, uniqueVertices: 'global' }
RETURN v.id
)
FILTER LENGTH(nch) > 0
FOR n IN nch
FOR z IN %s
FOR cvtn IN %s
FILTER n == cvtn.id
FILTER cvtn._id == z._to
FILTER cvt._id == z._from
INSERT {
_from: z._from,
_to: z._to,
predicate: z.predicate
} IN %s
COLLECT WITH COUNT INTO c
RETURN c
`
)

func termInsert(gname, gcoll, tcoll, temp string) string {
Expand All @@ -70,3 +98,11 @@ func termUpdate(gname, gcoll, tcoll, temp string) string {
gcoll, gname, tcoll, temp, temp, tcoll, tcoll,
)
}

func relInsert(gname, gcoll, tcoll, rcoll, graph, temp string) string {
return fmt.Sprintf(
rinst,
gcoll, tcoll, gname, temp,
tcoll, temp, tcoll, rcoll,
)
}

0 comments on commit 7fbf324

Please sign in to comment.