Skip to main content

Module db

Module db 

Source
Expand description

AimemDb — Turso connection wrapper + schema bootstrap.

§Overview

AimemDb wraps a turso::Database and owns the full schema lifecycle. It is cheaply cloneable (Arc-backed internally) and safe to share across async tasks.

§Schema

Three tables live in one file:

TablePurpose
drawersVerbatim text chunks + vector32 embeddings
entitiesKnowledge-graph entity nodes
triplesTemporal (subject→predicate→object) edges

§Example

use aimem_core::{Drawer, AimemDb};
use chrono::Utc;

// In-memory DB — perfect for tests
let db = AimemDb::memory().await?;

let drawer = Drawer::new(
    "d_001",
    "my_project",
    "decisions",
    "We chose Turso for native vector support.",
    "claude",
)
.with_filed_at(Utc::now().to_rfc3339());

let inserted = db.insert_drawer(&drawer, None).await?;
assert!(inserted);
assert_eq!(db.drawer_count().await?, 1);

Structs§

AimemDb
Shared Turso database handle.
EmbeddingStoreProfile

Enums§

DbError

Type Aliases§

DbResult