File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed
Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,36 @@ A Graph Database for Julia, built on top of [SQLite.jl](https://github.com/Julia
44
55## Quickstart
66
7- - * Nodes* and * Edges* must have "properties", even if ` nothing ` .
8- - The types returned by ` getindex ` (` Node ` /` Edge ` ) have a ` props ` field that contains the JSON String.
9- - You can read it as whatever type you wish with ` JSON3.read(node.props, T) `
7+ ``` julia
8+ using SQLiteGraph
9+
10+ db = DB ()
11+ # SQLiteGraph.DB(":memory:") (0 nodes, 0 edges)
12+ ```
1013
14+ - Nodes and edges must have "properties" (something that is ` JSON3.write ` -able), even if its ` nothing ` .
15+ - Nodes must have an id (` Int ` ) in ascending order starting with ` 1 ` .
16+ - Add nodes and edges with ` setindex! `
17+ - E.g. Node 1: ` db[1] = (x=1, y=2) `
18+ - E.g. Edge 1 → 2: ` db[1, 2] = (a=3, b=4) `
19+ - Query nodes and edges with ` getindex ` (as well as ` find_nodes ` /` find_edges ` ).
20+ - E.g. Nodes 1, 2, and 3: ` db[1:3] `
21+ - E.g. Edges from 1 to 2 or 3: ` db[1, 2:3] `
22+ - Returned objects are ` Node ` or ` Edge ` (or generator if multiple objects queried):
23+ - ` Node ` and ` Edge ` are simple structs. By default, ` T ` will be ` String ` .
24+ - To read ` props ` into Julia as a specific type, use ` JSON3.read(node.props, MyType) ` .
25+ ``` julia
26+ struct Node{T}
27+ id:: Int
28+ props:: T
29+ end
30+
31+ struct Edge{T}
32+ source:: Int
33+ target:: Int
34+ props:: T
35+ end
36+ ```
1137
1238### Creating a Graph Database
1339
You can’t perform that action at this time.
0 commit comments