Many thanks to Andrew Kane for maintaining the Ruby SDK for immudb! https://ankane.org/
You can find the Sources here: https://github.com/ankane/immudb-ruby and the Gem here: https://rubygems.org/gems/immudb
Installation
Add this line to your application’s Gemfile:
gem "immudb"
Getting Started
Create a client
immudb = Immudb::Client.new
All of these options are supported
Immudb::Client.new(
host: "localhost",
port: 3322,
username: "immudb",
password: "immudb",
database: "defaultdb",
timeout: nil
)
You can also use a URL. Set ENV["IMMUDB_URL"]
or use:
Immudb::Client.new(url: "immudb://user:pass@host:port/dbname")
Keys
Set and get keys
immudb.set("hello", "world")
immudb.get("hello")
Set and get keys with verification
immudb.verified_set("hello", "world")
immudb.verified_get("hello")
Set and get multiple keys
immudb.set_all({"a" => "one", "b" => "two"})
immudb.get_all(["a", "b"])
Get the history of a key
immudb.history("key")
Iterate over keys
immudb.scan
SQL
List tables
immudb.list_tables
Create a table
immudb.sql_exec("CREATE TABLE cities (id INTEGER, name VARCHAR, PRIMARY KEY id)")
Describe a table
immudb.describe_table("cities")
Execute a statement
immudb.sql_exec("INSERT INTO cities (id, name) VALUES (@id, @name)", {id: 1, name: "Chicago"})
Query data
immudb.sql_query("SELECT * FROM cities WHERE id = @id", {id: 1}).to_a
See the SQL Reference for more info