Skip to content

Commit 3a856ff

Browse files
committed
wip propertygraph
1 parent 01bd097 commit 3a856ff

File tree

3 files changed

+185
-198
lines changed

3 files changed

+185
-198
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ version = "0.1.0"
55

66
[deps]
77
DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965"
8+
EasyConfig = "acab07b0-f158-46d4-8913-50acef6d41fe"
89
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
910
SQLite = "0aa819cd-b072-5ff4-a722-6bc24af294d9"
1011

1112
[compat]
13+
DBInterface = "2"
1214
JSON3 = "1"
1315
SQLite = "1"
14-
DBInterface = "2"
1516
julia = "1"
1617

1718
[extras]

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ using SQLiteGraph
1313

1414
db = DB()
1515
# SQLiteGraph.DB(":memory:") (0 nodes, 0 edges)
16+
17+
db[1] = Config(type="person", name="Fred")
18+
19+
db[2] = Config(type="person", name="Robert Ford")
20+
21+
db[2, 1] = Config(shot=true)
1622
```
1723

24+
25+
1826
- Nodes and edges must have "properties" (something that is `JSON3.write`-able), even if its `nothing`.
1927
- Nodes must have an id (`Int`) in ascending order starting with `1`.
2028
- Add nodes and edges with `setindex!`
@@ -25,17 +33,17 @@ db = DB()
2533
- E.g. Edges from 1 to 2 or 3: `db[1, 2:3]`
2634
- Returned objects are `Node` or `Edge` (or generator if multiple objects queried):
2735
- `Node` and `Edge` are simple structs.
28-
- By default, `T` will be `String`. You can set `T` on construction of the `DB` e.g. `DB(Dict{String,String})`.
36+
2937
```julia
30-
struct Node{T}
38+
struct Node
3139
id::Int
32-
props::T
40+
props::Config
3341
end
3442

35-
struct Edge{T}
43+
struct Edge
3644
source::Int
3745
target::Int
38-
props::T
46+
props::config
3947
end
4048
```
4149

@@ -57,7 +65,9 @@ db[1] = (x=1, y=2)
5765
db[2] = (x=1, y=10)
5866

5967
db[1]
60-
# "{\"x\":1,\"y\":2}"
68+
# Node 1
69+
# • y: 2
70+
# • x: 1
6171
```
6272

6373
### Adding Edges
@@ -66,12 +76,18 @@ db[1]
6676
db[1, 2] = (a=1, b=2)
6777

6878
db[1, 2]
69-
# "{\"a\":1,\"b\":2}"
79+
# Edge 1 → 2
80+
# • a: 1
81+
# • b: 2
7082
```
7183

72-
## Querying
73-
84+
## Iteration
7485

86+
```julia
87+
for node in eachnode(db)
88+
println(getfield(node, :id))
89+
end
90+
```
7591

7692
### Querying Edges Based on Node ID
7793

0 commit comments

Comments
 (0)