Storine 0.3.0 · MIT or Apache-2.0
The document database that is fast, exact and small.
Embed it in a Rust program, run it as a server, or start three servers for a replicated cluster with automatic failover. Written in Rust, with no third-party dependencies.
curl -fsSL https://github.com/Twilight-Techy/storine/releases/latest/download/install.sh | sh
irm https://github.com/Twilight-Techy/storine/releases/latest/download/install.ps1 | iex
import storine
from decimal import Decimal
from storine import add, gt
db = storine.connect("storine://127.0.0.1:7878")
accounts = db.collection("accounts")
accounts.insert("alice", {"balance": Decimal("100.00")})
accounts.insert("bob", {"balance": Decimal("0.00")})
# Both changes or neither, and never below zero.
with db.transaction() as tx:
tx.update("accounts", "alice",
add("balance", Decimal("-10.00"), min=0))
tx.update("accounts", "bob",
add("balance", Decimal("10.00")))
accounts.create_index("balance")
rich = accounts.find(gt("balance", Decimal("50")))import { connect, add, gt, Decimal } from "storine";
const db = connect("storine://127.0.0.1:7878");
const accounts = db.collection("accounts");
await accounts.insert("alice", { balance: new Decimal("100.00") });
await accounts.insert("bob", { balance: new Decimal("0.00") });
// Both changes or neither, and never below zero.
await db.transaction((tx) => {
tx.update("accounts", "alice",
add("balance", new Decimal("-10.00"), { min: 0 }));
tx.update("accounts", "bob",
add("balance", new Decimal("10.00")));
});
await accounts.createIndex("balance");
const rich = await accounts.find(gt("balance", new Decimal("50")));db, err := storine.Connect("storine://127.0.0.1:7878")
if err != nil { return err }
defer db.Close()
accounts := db.Collection("accounts")
dec := storine.MustDecimal
accounts.Insert(ctx, "alice", storine.Doc{"balance": dec("100.00")})
accounts.Insert(ctx, "bob", storine.Doc{"balance": dec("0.00")})
// Both changes or neither, and never below zero.
_, err = db.Transaction(ctx, func(tx *storine.Tx) error {
tx.Update("accounts", "alice", storine.Add("balance", dec("-10.00")).Min(0))
tx.Update("accounts", "bob", storine.Add("balance", dec("10.00")))
return nil
})
rich, err := accounts.Find(ctx, storine.Query{Where: storine.Gt("balance", dec("50"))})use storine::{add, dec, doc, gt, Query};
let db = storine::connect("storine://127.0.0.1:7878")?;
let accounts = db.collection("accounts");
accounts.insert("alice", doc! { "balance" => dec("100.00") })?;
accounts.insert("bob", doc! { "balance" => dec("0.00") })?;
// Both changes or neither, and never below zero.
db.transaction(|tx| {
tx.update("accounts", "alice", [add("balance", dec("-10.00")).min(0)]);
tx.update("accounts", "bob", [add("balance", dec("10.00"))]);
Ok(())
})?;
let rich = accounts.find(Query::new().filter(gt("balance", dec("50"))))?;try (Storine db = Storine.connect("storine://127.0.0.1:7878")) {
Collection accounts = db.collection("accounts");
accounts.insert("alice", Map.of("balance", new BigDecimal("100.00")));
accounts.insert("bob", Map.of("balance", new BigDecimal("0.00")));
// Both changes or neither, and never below zero.
db.transaction(tx -> {
tx.update("accounts", "alice",
add("balance", new BigDecimal("-10.00")).min(0));
tx.update("accounts", "bob",
add("balance", new BigDecimal("10.00")));
});
var rich = accounts.find(new Query().where(gt("balance", new BigDecimal("50"))));
}await using var db = StorineClient.Connect("storine://127.0.0.1:7878");
var accounts = db.Collection("accounts");
await accounts.InsertAsync("alice", new Doc { ["balance"] = 100.00m });
await accounts.InsertAsync("bob", new Doc { ["balance"] = 0.00m });
// Both changes or neither, and never below zero.
await db.TransactionAsync(tx =>
{
tx.Update("accounts", "alice", Add("balance", -10.00m).Min(0));
tx.Update("accounts", "bob", Add("balance", 10.00m));
});
var rich = await accounts.FindAsync(Gt("balance", 50m));Everything a document database needs, in a few megabytes
Each tool is a single file with nothing else to install. The engine, the network server, TLS, the SQL gateway and the web console are all built from the Rust standard library.
Documents, done properly
Collections of JSON-like documents with versions, preconditions, time to live, and atomic writes across collections.
Exact money
Decimals up to 38 digits, mapped to each language's exact decimal type. Server-side add with bounds makes an overdraft impossible.
Queries and indexes
Filters on nested fields, sorting, keyset paging, up to 16 secondary indexes per collection, and exact results every time.
Vector search
Nearest-neighbour queries by cosine similarity, with an HNSW index for large collections and exact scoring of every candidate.
Analytics on the server
Grouped aggregates with exact sums, and an optional columnar copy of a collection for vectorized, parallel scans.
Secure by default
Tokens with roles, TLS for clients and between nodes, encryption at rest with key rotation, and point-in-time recovery.
Fast where it counts
A read takes about 60 nanoseconds in process and 9 microseconds over the network. Against LMDB and RocksDB at equal durability, Storine leads every throughput row.
One engine, three ways to run it
The same storage engine and the same data model, from a library call to a cluster that spreads data across regions.
Embedded
Link storage-core into a Rust program and open a store in a folder. No server, no network.
let store = DocumentStore::open("./data",
EngineConfig::default())?;
store.put("accounts", "alice", fields)?;Server
One process serves clients in eight languages, the SQL gateway and the web console.
storage-server ./data 127.0.0.1:7878
storine-console storine://127.0.0.1:7878Cluster
Three servers replicate with Raft and fail over on their own. Add --ranges to partition data and place it by region.
storage-server ./n1 10.0.0.1:7878 --node-id 1 \
--peers 1=10.0.0.1:7878,2=10.0.0.2:7878,3=10.0.0.3:7878Speaks your stack
Clients for eight languages share one API, need only their standard library, retry without ever applying a write twice, and follow a cluster's leader on their own. Apps written for PostgreSQL, MySQL or SQL Server can switch by changing a connection string.
Try it in a minute
Install the four tools, start a server, and open the console. The quick start walks through it in your language.