Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (optional) properties to edges #38

Merged
merged 24 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2462ff3
minor edit
drkameleon Nov 3, 2023
3b5b372
updated schema
drkameleon Nov 3, 2023
410a9b3
re-organize schema (a tiny bit)
drkameleon Nov 4, 2023
2d34b3b
updated `createEdge` proc
drkameleon Nov 4, 2023
850bf05
let's turn Debug mode to on
drkameleon Nov 4, 2023
c3cd3b1
updated `edge` implementation
drkameleon Nov 4, 2023
7e53a46
make `edge` accept the empty attribute (`.:`) as a way of passing opt…
drkameleon Nov 4, 2023
31157be
[UI] initial attempt to embed edge-bound properties into our breadcru…
drkameleon Nov 4, 2023
81dd509
[SQL] update `getRelatedNodes` to also fetch properties-related data …
drkameleon Nov 4, 2023
64d077a
...and put them inside the edge object we're sending to the UI
drkameleon Nov 4, 2023
53c8cf0
removed debugging `inspect`
drkameleon Nov 4, 2023
ca850d8
[UI] update code so that we can see edge properties when a specific e…
drkameleon Nov 4, 2023
c348abe
make `edgeFilter` type accept a 3 parameter (= filter properties)
drkameleon Nov 4, 2023
89938d4
prepare edge-related queries for embedding potential property filters
drkameleon Nov 4, 2023
8dabf37
renamed `propertyWithValue` to `nodePropertyWithValue`
drkameleon Nov 4, 2023
5375ab2
also rename all references to `propertyWithValue` + minor cleanup
drkameleon Nov 4, 2023
f7dd510
created new `edgePropertyWithValue` query filter
drkameleon Nov 4, 2023
e09c96e
declare our new filter within the main module too
drkameleon Nov 4, 2023
c77676b
initial implementation of edge-property filters
drkameleon Nov 4, 2023
014bc38
makes sure normal edge filters (without `|>`, `<|` & `<|>` calls) sti…
drkameleon Nov 4, 2023
2a72eaa
[SQL] added new `edgeWithProperties` filter
drkameleon Nov 4, 2023
dd9e4b1
trying to fix the whole thing...
drkameleon Nov 4, 2023
175a0ea
we have to add the edge property properly (like `$.property`)!
drkameleon Nov 4, 2023
db57cdd
I was missing that `AND (...)`, geez!
drkameleon Nov 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ graph "mygraph" [
preview fetch 'person ø
]
```

(If you run the `sample4` in the *examples* folder, you'll be a minimal movie database. Running the command `preview` will open up the Desktop app with the image you see above ;-))

### More complex queries
Expand Down
198 changes: 135 additions & 63 deletions grafito.art

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions sql/filters/edgePropertyWithValue.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(json_extract(edges.properties, ?)|collate| |symb| |val|)
2 changes: 1 addition & 1 deletion sql/filters/edgeWithAny.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(edges.tag=? AND (edges.target=? OR edges.source=?))
(edges.tag=? AND (edges.target=? OR edges.source=?) |searchForProperties|)
1 change: 1 addition & 0 deletions sql/filters/edgeWithProperties.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(edges.tag=? AND |searchForProperties|)
2 changes: 1 addition & 1 deletion sql/filters/edgeWithSource.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(edges.tag=? AND edges.source=?)
(edges.tag=? AND edges.source=? |searchForProperties|)
2 changes: 1 addition & 1 deletion sql/filters/edgeWithTarget.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(edges.tag=? AND edges.target=?)
(edges.tag=? AND edges.target=? |searchForProperties|)
4 changes: 2 additions & 2 deletions sql/procs/createEdge.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INSERT INTO edges (tag, source, target)
VALUES (?, ?, ?)
INSERT INTO edges (tag, properties, source, target)
VALUES (?, ?, ?, ?)
2 changes: 1 addition & 1 deletion sql/procs/getRelatedNodes.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT nodes.id, nodes.tag, nodes.properties, source, target, edges.tag, edges.id AS label
SELECT nodes.id, nodes.tag, nodes.properties, source, target, edges.tag, edges.id AS label, edges.properties
FROM edges
INNER JOIN nodes
ON nodes.id=edges.source OR nodes.id=edges.target
Expand Down
1 change: 1 addition & 0 deletions sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DROP TABLE IF EXISTS edges;
CREATE TABLE edges (
id INTEGER PRIMARY KEY,
tag TEXT,
properties JSON NOT NULL,
source INTEGER,
target INTEGER,
FOREIGN KEY (source) REFERENCES nodes(id),
Expand Down
18 changes: 14 additions & 4 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,17 @@
</li>
</template>
<template v-else-if="graph.hovered.edge != null">
<li class="is-active edged">
<li class="is-active" v-for="(value, key) in graph.hovered.edge.properties">
<a>
<b>{{key}}:</b>{{value}}
</a>
</li>
<!-- <li class="is-active edged">
<a><b>{{graph.data.nodes.get(graph.hovered.edge.from).tag}}:</b>{{graph.data.nodes.get(graph.hovered.edge.from).fullLabel}}</a>
</li>
<li class="is-active edged">
<a><b>{{graph.data.nodes.get(graph.hovered.edge.to).tag}}:</b>{{graph.data.nodes.get(graph.hovered.edge.to).fullLabel}}</a>
</li>
</li> -->
</template>
<template v-else>
<li class="is-active">
Expand All @@ -561,12 +566,17 @@
</li>
</template>
<template v-else-if="graph.selected.node.length==0 && graph.selected.edge.length==1">
<li class="is-active edged">
<li class="is-active" v-for="(value, key) in graph.selected.edge[0].properties">
<a>
<b>{{key}}:</b>{{value}}
</a>
</li>
<!-- <li class="is-active edged">
<a><b>{{graph.data.nodes.get(graph.selected.edge[0].from).tag}}:</b>{{graph.data.nodes.get(graph.selected.edge[0].from).fullLabel}}</a>
</li>
<li class="is-active edged">
<a><b>{{graph.data.nodes.get(graph.selected.edge[0].to).tag}}:</b>{{graph.data.nodes.get(graph.selected.edge[0].to).fullLabel}}</a>
</li>
</li> -->
</template>
<template v-else>
<li class="is-active">
Expand Down
Loading