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

Swift

Swift client for ChronDB, auto-generated from the Rust SDK via UniFFI.

Requirements

  • Swift 5.5+

  • macOS 12+ or Linux

Installation

Download the platform-specific tarball from the latest GitHub release:

  • chrondb-swift-{version}-macos-aarch64.tar.gz (macOS Apple Silicon)

  • chrondb-swift-{version}-linux-x86_64.tar.gz (Linux x86_64)

Extract and add as a local Swift package dependency:

// In your Package.swift
.package(path: "path/to/chrondb-swift")

Quick Start

import ChronDB

// Single path (preferred)
let db = try ChronDB.openPath(dbPath: "./mydb")

// Save a document
try db.put(id: "user:1", jsonDoc: #"{"name": "Alice", "age": 30}"#, branch: nil)

// Retrieve it
let doc = try db.get(id: "user:1", branch: nil)
print(doc) // {"name":"Alice","age":30}

Legacy API (deprecated): ChronDB.open(dataPath:indexPath:) still works but is deprecated. Use openPath instead.

API Reference

ChronDB.openPath(dbPath:) throws -> ChronDB

Opens a database connection using a single directory path. Data and index are stored in subdirectories automatically.

ChronDB.open(dataPath:indexPath:) throws -> ChronDB (deprecated)

Deprecated. Use openPath instead. This method still works but will be removed in a future release.

ChronDB.openWithIdleTimeout(dataPath:indexPath:idleTimeoutSecs:) throws -> ChronDB

Opens a database with idle timeout.

Operations

Method
Description

put(id:jsonDoc:branch:)

Save a document

get(id:branch:)

Get a document by ID

delete(id:branch:)

Delete a document

listByPrefix(prefix:branch:)

List by ID prefix

listByTable(table:branch:)

List by table

history(id:branch:)

Get change history

query(queryJson:branch:)

Execute a Lucene query

executeSql(sql:branch:)

Execute a SQL query directly

Error Handling

Examples

SQL Queries

Execute SQL queries directly without needing a running server:

Idle Timeout

Last updated

Was this helpful?