datom-rs

An open-source database inspired by Datomic

use datom::{
    prelude::*,
    sled::SledConnection,
    Transaction, ID, Value, EntityResult,
};

// Create a temporary database
let conn = SledConnection::connect_temp()?;

// Create an ID to use for the username attribute
let username = ID::new();
// Create an ID to use for the user's entity
let user = ID::new();

// Create a transaction setting the username attribute on the user entity to "pmc"
let mut tx = Transaction::new();
tx.add(user.into(), username.into(), "pmc".into());
// Execute the transaction using the connection
conn.transact(tx)?;

// Get a view of the database in the current point in time
let db = conn.db()?;
// Get the value of the username attribute on the user entity
if let EntityResult::Value(Value::String(u)) = db.entity(user.into())?.get(username.into())? {
    println!("The user's username is {}.", u);
}

Versions

Version Cargo.toml line Documentation Source
v0.1.1-pre datom = "0.1.1-pre" docs.rs GitHub
v0.1.1-pre2 datom = "0.1.1-pre2" docs.rs GitHub
v0.1.1-pre3 datom = "0.1.1-pre3" docs.rs GitHub
Development datom = { git = "https://github.com/LutrisEng/datom-rs" } os.lutris.engineering GitHub

Sponsors

Sponsor Contribution
Lutris Engineering Lutris Engineering runs the datom-rs project.
// SPDX-FileCopyrightText: 2021 Lutris Engineering, Inc
// SPDX-License-Identifier: BlueOak-1.0.0 OR BSD-2-Clause-Patent