Namespace: joker.bolt
v1.0Contents
Summary
Provide API for Bolt embedded database https://github.com/etcd-io/bbolt.
Example:
user=> (def db (joker.bolt/open "bolt.db" 0600))
#'user/db
user=> (joker.bolt/create-bucket db "users")
nil
user=> (def id (joker.bolt/next-sequence db "users"))
#'user/id
user=> id
1
user=> (joker.bolt/put db "users" (str id) (joker.json/write-string {:id id :name "Joe Black"}))
nil
user=> (joker.json/read-string (joker.bolt/get db "users" (str id)))
{"id" 1, "name" "Joe Black"}
Index
- by-prefix
- close
- create-bucket
- create-bucket-if-not-exists
- delete
- delete-bucket
- get
- next-sequence
- open
- put
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
by-prefix
Function v1.0(by-prefix db bucket prefix)
Retrives key/value pairs for all keys in bucket
that start with prefix.
Returns a vector of [key value] tuples. Passing empty prefix
will return all key/values in bucket. -
close
Function v1.0(close db)
Releases all database resources.
It will block waiting for any open transactions to finish
before closing the database and returning. -
create-bucket
Function v1.0(create-bucket db name)
Creates a new bucket. Throws an error if the bucket already exists,
if the bucket name is blank, or if the bucket name is too long. -
create-bucket-if-not-exists
Function v1.0(create-bucket-if-not-exists db name)
Creates a new bucket if it doesn't already exist.
Throws an error if the bucket name is blank, or if the bucket name is too long. -
delete
Function v1.0(delete db bucket key)
Removes a key from the bucket if it exists.
-
delete-bucket
Function v1.0(delete-bucket db name)
Deletes a bucket. Throws an error if the bucket doesn't exist.
-
get
Function v1.0(get db bucket key)
Retrieves the value for a key in the bucket.
Returns nil if the key does not exist. -
next-sequence
Function v1.0(next-sequence db bucket)
Returns an autoincrementing integer for the bucket.
-
open
Function v1.0(open filename mode)
Creates and opens a database at the given path.
If the file does not exist then it will be created automatically
with mode perm (before umask).
mode is normally passed as an octal literal, e.g. 0600 -
put
Function v1.0(put db bucket key value)
Sets the value for a key in the bucket.
If the key exist then its previous value will be overwritten.
Throws an error if the key is blank, if the key is too large, or if the value is too large.