For the complete documentation index, see llms.txt. This page is also available as Markdown.

Clojure Examples

This document provides detailed examples for using the ChronDB native Clojure API, which is the most direct way to interact with ChronDB.

Setup

First, add ChronDB as a dependency in your project:

deps.edn

{:deps {com.github.avelino/chrondb {:git/tag "v0.1.0"
                                     :git/sha "..."}}}

Leiningen (project.clj)

:dependencies [[com.github.avelino/chrondb "0.1.0"]]

Basic Usage

Creating a Database

(ns my-app.core
  (:require [chrondb.core :as chrondb]))

;; Create with default configuration (in-memory database)
(def db (chrondb/create-chrondb))

;; Create with custom configuration
(def config {:git {:committer-name "My App"
                  :committer-email "[email protected]"}
             :storage {:data-dir "/path/to/storage"}})
(def db (chrondb/create-chrondb config))

CRUD Operations

Searching

ChronDB uses Lucene for powerful search capabilities:

Version Control Features

Working with Document History

Working with Branches

Transactions

ChronDB supports atomic transactions:

You can customise the transaction metadata written to Git notes via the chrondb.transaction.core helpers:

Advanced Features

Custom Hooks

Database Statistics and Maintenance

Integration with Other Systems

Creating a REST API Server

Performance Tips

  • Use the appropriate branch strategy for your application

  • For large datasets, consider indexing only the fields you search frequently

  • Use transactions for operations that need to be atomic

  • For read-heavy workloads, consider using a caching layer

  • Monitor disk usage regularly, as historical data will grow over time

  • Use the compact operation periodically to optimize storage

Last updated

Was this helpful?