@@ -13,8 +13,16 @@ using SQLiteGraph
1313
1414db = 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)
5765db[2 ] = (x= 1 , y= 10 )
5866
5967db[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]
6676db[1 , 2 ] = (a= 1 , b= 2 )
6777
6878db[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