add do-block way to create/open a database, given a schema
parent
3ae8fd2d12
commit
0ed8bef3a4
|
@ -10,6 +10,7 @@ using MsgPack
|
||||||
|
|
||||||
include("actions.jl")
|
include("actions.jl")
|
||||||
include("structure.jl")
|
include("structure.jl")
|
||||||
|
include("db_init.jl")
|
||||||
|
|
||||||
function Base.push!(stream::IOStream, object::T) where T
|
function Base.push!(stream::IOStream, object::T) where T
|
||||||
write(stream, Action(create, object))
|
write(stream, Action(create, object))
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
"DataBase(path) do db:DataBase
|
||||||
|
end
|
||||||
|
|
||||||
|
Load a database, or create it from a schema"
|
||||||
|
function DataBase(f, path::String)
|
||||||
|
db = if isdir(path)
|
||||||
|
DataBase(path, verbose = true);
|
||||||
|
else
|
||||||
|
let db = DataBase(path, verbose = true);
|
||||||
|
f(db)
|
||||||
|
db
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue