Skip to content

Commit cfb5300

Browse files
committed
query by node label
1 parent dff9ce1 commit cfb5300

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/SQLiteGraph.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function Base.show(io::IO, o::Node)
3838
!isempty(o.props) && print(io, "; "); print_props(io, o.props)
3939
print(io, ')')
4040
end
41-
args(n::Node) = (n.id, isempty(n.labels) ? "" : join(n.labels, ';'), JSON3.write(n.props))
41+
args(n::Node) = (n.id, isempty(n.labels) ? "" : ";"*join(n.labels, ';')*";", JSON3.write(n.props))
4242

4343

4444

@@ -148,6 +148,7 @@ end
148148
#-----------------------------------------------------------------------------# getindex (Node)
149149
Base.getindex(db::DB, i::Integer) = Node(first(query(db, "*", "nodes", "id=$i")))
150150
Base.getindex(db::DB, ::Colon) = (Node(row) for row in query(db, "*", "nodes", "TRUE"))
151+
Base.getindex(db::DB, label::String) = (Node(row) for row in SQLiteGraph.query(db, "*", "nodes", "labels LIKE '%;$label;%'"))
151152

152153
#-----------------------------------------------------------------------------# getindex (Edge)
153154
# all specified

0 commit comments

Comments
 (0)