Ruby
Ruby client for ChronDB, auto-generated from the Rust SDK via UniFFI.
Requirements
Ruby 3.0+
Installation
gem install chrondbQuick Start
require "chrondb"
# Single path (preferred)
db = ChronDB::Client.new("./mydb")
# Save a document
db.put("user:1", { name: "Alice", age: 30 })
# Retrieve it
doc = db.get("user:1")
puts doc # {"name"=>"Alice", "age"=>30}Legacy API (deprecated):
ChronDB::Client.new("/tmp/data", "/tmp/index")still works but is deprecated. Use the single-path form instead.
API Reference
ChronDB::Client.new(db_path, idle_timeout: nil)
Opens a database connection using a single directory path.
db_path
String
Path for the database (data and index stored inside)
idle_timeout
Integer
Seconds of inactivity before suspending the GraalVM isolate
Raises: ChronDB::Error if the database cannot be opened.
Legacy: ChronDB::Client.new(data_path, index_path, idle_timeout: nil)
Deprecated. The two-path constructor still works but is deprecated. Use the single-path form above.
data_path
String
Path for the Git repository (data storage)
index_path
String
Path for the Lucene index
idle_timeout
Integer
Seconds of inactivity before suspending the GraalVM isolate
put(id, doc, branch: nil) -> Hash
Saves a document.
id
String
Document ID (e.g., "user:1")
doc
Hash
Document data
branch
String
Branch name (nil for default)
get(id, branch: nil) -> Hash
Retrieves a document by ID.
Raises: ChronDB::DocumentNotFoundError if not found.
delete(id, branch: nil) -> true
Deletes a document by ID.
Raises: ChronDB::DocumentNotFoundError if not found.
list_by_prefix(prefix, branch: nil) -> Array<Hash>
Lists documents whose IDs start with the given prefix.
list_by_table(table, branch: nil) -> Array<Hash>
Lists all documents in a table.
history(id, branch: nil) -> Array<Hash>
Returns the change history of a document.
query(query, branch: nil) -> Hash
Executes a query against the Lucene index.
execute(sql, branch: nil) -> Hash
Executes a SQL query directly against the database without needing a running server.
sql
String
SQL query string
branch
String
Branch name (nil for default)
Returns: Hash with keys type, columns, rows, count.
Raises: ChronDB::Error on failure.
Error Handling
Examples
Full CRUD
Idle Timeout (long-running services)
SQL Queries
Execute SQL queries directly without needing a running server:
Query
History (Time Travel)
Export & Backup
Export to Directory
Backup & Restore
Last updated
Was this helpful?