dWeb University

dDatabase Vaultr

Solution for vaulting multiple dDatabases or dDrives


var vaultr = require('@ddatabase/vaultr')
var ddatabase = require('@ddatabase/core')

var ar = vaultr('./vaultr') // also supports passing in a storage provider
var ddb = ddatabase('./ddbs')

ddb.on('ready', function () {
  ar.add(ddb.key, function (err) {
    console.log('Will now vault the ddb')

ar.on('sync', function (ddb) {
  console.log('Ddb is synced', ddb.key)

// setup replication
var stream = ar.replicate()
stream.pipe(ddb.replicate({live: true})).pipe(stream)

ddb.append(['greetings', 'martian'])


var ar = vaultr(storage, [key], [options])

Create a new vaultr. storage can be a file system path or a storage provider like @dwcore/rem.

If this vaultr is a fork of another vaultr pass the changes ddb key as the 2nd argument.

Options include

  thin: false // set to true to only vault blocks you request
Thin File Storage

The thin option uses thin file mode, only available on some file systems. It will appear as a full size file but only take up the space actually used on disk.

  • Use ls -alsh to view the actual size (first column)
  • thin file mode (APFS) is not available on Mac OSX.

ar.add(key, [callback])

Add a new ddatabase or ddrive key to be vaultd.

ar.remove(key, [callback])

Remove a key.


List all ddatabases and ddrives being vaultd.

ar.import(vaultrKey, callback)

Add all ddatabases vaulted in another ddb-vaultr instance

ar.get(key, callback)

Retrieve the ddb being vaultd. If the key points to a ddrive the callback is called with (err, metadataDdb, contentDdb)


A changes ddb containing the vaultr state. Pass the changes ddb key to another ddatabase vaultr to replicate the vaultr and all ddbs

var stream = ar.replicate([options])

Create a replication stream. Per defaults the vaultr will replicate any ddb the remote asks for.
To have the vaultr ask to replicate one pass in {key: ddbKey} as an option.

ar.on('add', ddb)

Emitted when a ddb is being added

ar.on('add-vault', metadataDdb, contentDdb)

Emitted if a ddb is identified as a dDrive vault

ar.on('remove', ddb)

Emitted when a ddb is being removed

ar.on('sync', ddb)

Emitted when a ddb has been fully synced

ar.on('download', ddb, index, data, peer)

Emitted when the vaultr downloads a block of data

ar.on('upload', ddb, index, data, peer)

Emitted when the vaultr uploads a block of data


Emitted when all internal state has been loaded (the changes ddb will be set). You do not have to wait for this event before calling any async function.

Network Flock

The vaultr comes with a network flock as well. This will make the vaultr replicate over the internet and local network.
To use it do:

var flock = require('ddb-vaultr/flock')

The flock listens on port 3282, both tcp and udp. If you require a different port, pass in the port as an option

var flock = require('ddb-vaultr/flock')
flock(vaultr, {port: 60234})

Updated about a year ago

dDatabase Vaultr

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.