Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Full Package

Add RouchDB to your project with all features:

[dependencies]
rouchdb = "0.1"
tokio = { version = "1", features = ["full"] }
serde_json = "1"

This gives you local storage (redb), HTTP client, replication, queries, and the high-level Database API.

Minimal Setup

If you only need local storage without replication or HTTP:

[dependencies]
rouchdb-core = "0.1"
rouchdb-adapter-redb = "0.1"
tokio = { version = "1", features = ["full"] }
serde_json = "1"

Individual Crates

Pick exactly what you need:

CrateWhat it adds
rouchdb-coreTypes, traits, revision tree, collation, errors
rouchdb-adapter-memoryIn-memory adapter (testing, ephemeral data)
rouchdb-adapter-redbPersistent local storage via redb
rouchdb-adapter-httpCouchDB HTTP client adapter
rouchdb-changesChanges feed (one-shot and live streaming)
rouchdb-replicationCouchDB replication protocol
rouchdb-queryMango selectors and map/reduce views
rouchdb-viewsDesign documents and persistent view engine
rouchdbUmbrella crate — re-exports everything above

Async Runtime

RouchDB is built on Tokio. All database operations are async and require a Tokio runtime:

#[tokio::main]
async fn main() -> rouchdb::Result<()> {
    let db = rouchdb::Database::memory("mydb");
    // ... your code here
    Ok(())
}

Verifying the Installation

use rouchdb::Database;

#[tokio::main]
async fn main() -> rouchdb::Result<()> {
    let db = Database::memory("test");

    let result = db.put("hello", serde_json::json!({"msg": "it works!"})).await?;
    assert!(result.ok);

    let doc = db.get("hello").await?;
    println!("{}", doc.data["msg"]); // "it works!"

    Ok(())
}

If this compiles and prints "it works!", you’re all set. Head to the Quickstart.