Skip to content
dddb a simple dlang database build on top of std.json
Branch: master
Clone or download
cvsae Merge pull request #3 from Mek101/patch-1
Fixed formatting and exception messages grammar
Latest commit 00da0cc Apr 21, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
source Fixed formatting and exception messages grammar Mar 30, 2019
.travis.yml Update .travis.yml Mar 25, 2018 Update Mar 25, 2018 Update Jul 1, 2018
dub.json First commit Mar 22, 2018


Build Status

dddb is lightweight and simple key-value dlang database (store) build on top of std.json


import std.stdio;
import dddb;

void main()
	auto db = new ddb("yes.db");

    // set multiple values to social_networks
    db.set("social_networks", "facebook");
    db.set("social_networks", "twitter");
    db.set("social_networks", "linkedin");

    // ["facebook", "twitter", "linkedin"]

    // will return 3, because we have add ["facebook", "twitter", "linkedin"]

    assert(db.count("social_networks") == 3);
    // no error because there are 3 ["facebook", "twitter", "linkedin"]

    db.update("social_networks", "facebook", "instagram");
    // update facebook to instagram 
    // ["instagram", "twitter", "linkedin"]

    assert(db.countkeys() == 1);
    // db.getkeys() return a list of all keys,
    // ["social_networks"]

    assert(db.getsize() == 54);
    // db.getsize() return the database size in bytes
    // 58

    assert(db.havevalue("social_networks", "facebook") == false);
    writeln(db.havevalue("social_networks", "facebook")); // expected false
    // because facebook not exists in social_networks, we update it with instagram in line 240

    assert(db.havevalue("social_networks", "instagram") == true);
    writeln(db.havevalue("social_networks", "instagram")); // expected true 
    // true 

    // db.drop() delete database 
    // NOTE: all db data will be lost
    assert(exists(db.db) == false);
You can’t perform that action at this time.