Skip to content

Experiments in writing a SQLite backed database similar to Datomic.

Notifications You must be signed in to change notification settings

the-kenny/hellschreiber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hellschreiber

Build Status

Experiments in writing a SQLite backed database similar to Datomic.

Examples

extern crate hellschreiber;
extern crate chrono;

use hellschreiber::{Db, SqliteDb, Assert, Value};

fn main() {
    // Open an in-memory DB
    let mut db = SqliteDb::new().expect("Failed to open DB");

    // Transact Schema
    let schema = &[(Assert, db.tempid(), "db/ident", "diary.entry/text"),
                   (Assert, db.tempid(), "db/ident", "diary.entry/date")];
    db.transact(schema).expect("Failed to transact schema");

    // Get temporary ID for our diary entry
    let entry_tempid = db.tempid();
    // A list of facts to be asserted.
    let tx = &[(Assert, entry_tempid, "diary.entry/date", Value::DateTime(chrono::Utc::now())),
               (Assert, entry_tempid, "diary.entry/text", "Hello World!".into())];
    let tx_data = db.transact(tx).expect("Failed to transact diary entry");

    // `tx_data` maps from our tempid `entry` to the real EntityId:
    let entity_id = tx_data.tempid_mappings[&entry_tempid];
    println!("Diary entry entity: {:?}", db.entity(entity_id).unwrap());
}

About

Experiments in writing a SQLite backed database similar to Datomic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages