JsonDB

Build Status

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

Functions

JsonDB.DatabaseType

JsonDB.Database

This type holds instance of database

Base.haskeyMethod

Base.haskey(db::Database, key)

Returns true if key is present in the database else returns false

Base.lengthFunction

Base.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.appendMethod

JsonDB.append(db::Database, key, more)

Adds more to keys's value

JsonDB.appendMethod

JsonDB.append(db::Database, name::String, pos::Integer, more)

Appends more to value at index pos in array with label name

JsonDB.append_arrayMethod

JsonDB.append_array(db::Database, name::String, seq)

Appends more to the array with label name

JsonDB.create_arrayMethod

JsonDB.create_array(db::Database, name::String)

Create an array as key with label name

JsonDB.create_dictMethod

JsonDB.create_dict(db::Database, name::String)

Creates a dictionary with label name

JsonDB.deleteMethod

JsonDB.delete(db::Database, key)

Deletes key from the database

JsonDB.delete_arrayMethod

JsonDB.delete_array(db::Database, name::String)

Deletes array with key/label name from the database

JsonDB.delete_dictMethod

JsonDB.delete_dict(db::Database, name::String)

Deletes dictionary with label name and all of its keys

JsonDB.delete_valueMethod

JsonDB.delete_value(db::Database, name::String, value)

Deletes value from array with label name

JsonDB.deletedbMethod

JsonDB.deletedb(db::Database)

Deletes everyhing from the database db

JsonDB.dumpMethod

JsonDB.dump(db::Database)

Force dump databse to memory

JsonDB.getMethod

JsonDB.get(db::Database, key)

Get value of the key

JsonDB.getMethod

JsonDB.get(db::Database, name::String, pos::Integer)

Returns value at pos from an array with label name

JsonDB.getallMethod

JsonDB.getall(db::Database)

Returns iterator over all keys in the database

JsonDB.haskeyMethod

JsonDB.haskey(db::Database, name::String, key)

Checks whether key is in dictionary with label name

JsonDB.hasvalueMethod

JsonDB.hasvalue(db::Database, name::String, value)

Returns true if value is present in array with label name else returns false

JsonDB.keysMethod

JsonDB.keys(db::Database, name::String)

Returns iterator over all the keys in dictionary with label name

JsonDB.loadFunction

JsonDB.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.mergeMethod

JsonDB.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.popMethod

JsonDB.pop(db::Database, name::String, pos)

In case of array deletes the value at index posfrom array with label name In case of dictionary deletes the value with key pos from dictionary with label name

JsonDB.rangeMethod

JsonDB.range(db::Database, name::String, _start, _end)

Returns slice from array with label name with starting index _start and ending index _end

JsonDB.setMethod

JsonDB.set(db::Database, key, value)

Insert key-value pair into the database

JsonDB.set_arrayMethod

JsonDB.set_array(db::Database, name::String, value)

Adds value to array with label name

JsonDB.set_dictMethod

JsonDB.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.valuesMethod

`JsonDB.values(db::Database, name::String)

Returns iterator over all the values in dictionary with label name