merkle-db.connection

Connections are stateful components which manage database identity and versioning. A connection is generally backed by a merkledag node store and a ref tracker.

More advanced connection implementations may optionally implement additional logic controlling updates, such as locking, conflict resolution, and authorization rules.

connect

(connect store tracker)

Create a new connection to some backing storage and ref tracker.

IConnection

protocol

Protocol for interacting with backing connection resources to work with one or more databases.

members

commit!

(commit! conn db)(commit! conn db opts)

Ensure all data has been written to the backing block store and update the database’s root value in the ref manager.

  • :force commit even if the versions don’t match

create-db!

(create-db! conn db-name attrs)

Initialize a new database. Optional attributes may be provided to merge into the root node data. If the attributes include a :merkledag.node/id, the database will use it as the root node.

drop-db!

(drop-db! conn db-name)

Drop a database reference. Note that this will not remove block data, as it may be shared.

get-db-history

(get-db-history conn db-name)(get-db-history conn db-name opts)

Retrieve a history of the versions of the database.

Options may include:

  • :offset Skip this many matching results.
  • :limit Return at most this many results.

list-dbs

(list-dbs conn)(list-dbs conn opts)

List information about the available databases.

Options may include:

  • :named If set to a string, return databases whose names are prefixed by the value. This may also be a regular expression to match database names against.
  • :offset Skip this many matching results.
  • :limit Return at most this many results.

open-db

(open-db conn db-name)(open-db conn db-name opts)

Open a database for use.

  • :version open a specific version of the database