Crate datom[][src]

Expand description

An open-source database inspired by Datomic.

// SPDX-FileCopyrightText: 2021 Lutris Engineering, Inc
// SPDX-License-Identifier: BlueOak-1.0.0 OR BSD-2-Clause-Patent
// SPDX-FileContributor: Piper McCorkle <piper@lutris.engineering>

Currently built on top of sled, a modern embedded database, and is only suitable for embedded usage. Future multi-peer support is planned.

If you aren’t already familiar with Datomic, it might help to look over Datomic’s excellent documentation. To the user, datom-rs functions extremely similarly to Datomic.

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

let conn = SledConnection::connect_temp("my_database")?;

let username = ID::new();
let user = ID::new();

let mut tx = Transaction::new();
tx.add(user.into(), username.into(), "pmc".into());
conn.transact(tx)?;

let db = conn.db()?;
if let Some(Value::String(u)) = db.entity(user.into())?.get(username.into())? {
    println!("pmc's username is {}.", u);
}

Modules

IDs for the built-in attributes and other idents

The main traits which should be in scope when using datom-rs

Serialization/deserialization functions

sled storage backend

Structs

A datom, or a single fact at a single point in time. Short for data atom.

An entity ID

n sorted iterators, merged

A set of facts which can be transacted into a database connection

The result of running a Transaction on a Connection

Enums

Network/disk errors

Whether a datom is showing an addition or a retraction

An un-resolved entity ID, which can be used to resolve entities by ident or unique attribute

A fact which hasn’t yet been converted to a Datom (or set of Datoms)

The four indices used in the underlying data store. The names refer to the serialization order, and by extension the sort order.

Errors during a Database query

Errors during a Transaction

An attribute value.

Traits

A persistent connection to a database

A snapshot of the database at a single point in time. That point in time is referred to as the database’s basis-t.

An entity at a single point in time