JsonDB
JsonDB is a lightweight and simple key-value store written in Julia, heavily inspired by Python's PickleDB
Example
julia> using JsonDB
julia> const d = JsonDB
julia> db = d.load("test.db", false)
Main.JsonDB.Database(Dict{Any,Any}(), nothing, "test.db", false)
julia> d.set(db, "fizz", "buzz")
true
julia> d.get(db, "fizz")
"buzz"
julia> d.dump(db)
true
Index
JsonDB.Database
Base.haskey
Base.length
JsonDB.append
JsonDB.append
JsonDB.append_array
JsonDB.create_array
JsonDB.create_dict
JsonDB.delete
JsonDB.delete_array
JsonDB.delete_dict
JsonDB.delete_value
JsonDB.deletedb
JsonDB.dump
JsonDB.get
JsonDB.get
JsonDB.getall
JsonDB.haskey
JsonDB.hasvalue
JsonDB.keys
JsonDB.load
JsonDB.merge
JsonDB.pop
JsonDB.range
JsonDB.set
JsonDB.set_array
JsonDB.set_dict
JsonDB.values
Functions
JsonDB.Database
— TypeJsonDB.Database
This type holds instance of database
Base.haskey
— MethodBase.haskey(db::Database, key)
Returns true
if key
is present in the database else returns false
Base.length
— FunctionBase.length(db::Database, name=nothing)
Returns total number of key/value pairs in the database if name
is nothing
else returns length of the value with key name
JsonDB.append
— MethodJsonDB.append(db::Database, key, more)
Adds more
to keys
's value
JsonDB.append
— MethodJsonDB.append(db::Database, name::String, pos::Integer, more)
Appends more
to value at index pos
in array with label name
JsonDB.append_array
— MethodJsonDB.append_array(db::Database, name::String, seq)
Appends more
to the array with label name
JsonDB.create_array
— MethodJsonDB.create_array(db::Database, name::String)
Create an array as key with label name
JsonDB.create_dict
— MethodJsonDB.create_dict(db::Database, name::String)
Creates a dictionary with label name
JsonDB.delete
— MethodJsonDB.delete(db::Database, key)
Deletes key
from the database
JsonDB.delete_array
— MethodJsonDB.delete_array(db::Database, name::String)
Deletes array with key/label name
from the database
JsonDB.delete_dict
— MethodJsonDB.delete_dict(db::Database, name::String)
Deletes dictionary with label name
and all of its keys
JsonDB.delete_value
— MethodJsonDB.delete_value(db::Database, name::String, value)
Deletes value
from array with label name
JsonDB.deletedb
— MethodJsonDB.deletedb(db::Database)
Deletes everyhing from the database db
JsonDB.dump
— MethodJsonDB.dump(db::Database)
Force dump databse to memory
JsonDB.get
— MethodJsonDB.get(db::Database, key)
Get value of the key
JsonDB.get
— MethodJsonDB.get(db::Database, name::String, pos::Integer)
Returns value at pos
from an array with label name
JsonDB.getall
— MethodJsonDB.getall(db::Database)
Returns iterator over all keys in the database
JsonDB.haskey
— MethodJsonDB.haskey(db::Database, name::String, key)
Checks whether key
is in dictionary with label name
JsonDB.hasvalue
— MethodJsonDB.hasvalue(db::Database, name::String, value)
Returns true
if value
is present in array with label name
else returns false
JsonDB.keys
— MethodJsonDB.keys(db::Database, name::String)
Returns iterator over all the keys in dictionary with label name
JsonDB.load
— FunctionJsonDB.load(path::String, auto_dump::Bool)
Returns a Database object which is stored at path
. Flag auto_dump
determines whether to dump the databse to disk after every set(write), update and delete operation.
JsonDB.merge
— MethodJsonDB.merge(db::Database, name1::String, name2::String)
Merge the dictionary with label name2
into the dictionary with label name1
. See the documentation for [Base.merge]
(https://docs.julialang.org/en/v1/base/collections/#Base.merge)
JsonDB.pop
— MethodJsonDB.pop(db::Database, name::String, pos)
In case of array deletes the value at index pos
from array with label name
In case of dictionary deletes the value with key pos
from dictionary with label name
JsonDB.range
— MethodJsonDB.range(db::Database, name::String, _start, _end)
Returns slice from array with label name
with starting index _start
and ending index _end
JsonDB.set
— MethodJsonDB.set(db::Database, key, value)
Insert key-value pair into the database
JsonDB.set_array
— MethodJsonDB.set_array(db::Database, name::String, value)
Adds value
to array with label name
JsonDB.set_dict
— MethodJsonDB.set_dict(db::Database, name::String, pair)
Adds a key/value pair to dictionary with label name
. pair
can be an array or tuple of length 2
JsonDB.values
— Method`JsonDB.values(db::Database, name::String)
Returns iterator over all the values in dictionary with label name