Manage multiple dat instances
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml . Feb 1, 2017
LICENSE . Feb 1, 2017 (readme) update multidat.create parameter docs Dec 29, 2017
index.js Exposing the (new) disconnect method of multidrive. Jan 26, 2018
package.json 5.1.0 Jan 27, 2018
test.js fix manifest test by turning off indexing Jan 26, 2018

multidat stability

npm version build status test coverage downloads js-standard-style

Manage multiple dat instances in multiple locations.


var Multidat = require('multidat')
var toilet = require('toiletdb')

var db = toilet('/tmp/dat')
Multidat(db, function (err, multidat) {
  if (err) throw err

  multidat.create(opts, function (err, dat) {
    if (err) throw err

    var dats = multidat.list()

    multidat.close(dat.archive.key, function (err) {
      if (err) throw err

Error handling

If there is an error initializing a dat, instead of the whole process failing, an error object with attached .dir property will be pushed into the list of dats instead. That means when consuming multidat.list(), you should check for errors:

var dats = multidat.list()
dats.forEach(function (dat) {
  if (dat instanceof Error) {
    var err = dat
    console.log('failed to initialize dat in %s: %s', err.dir, err.message)

This way you can decide for yourself whether an individual initialization failure should cause the whole process to fail or not.


Multidat(db, opts, callback(err, multidat))

Creat a new Multidat instance. Takes a toiletdb instance and a callback.


  • Dat: Use provided dat factory instead of dat-node

multidat.create(dir, opts, callback(err, dat))

Create a new dat archive.

dats = multidat.list()

List all available dat archives.

multidat.close(key, callback(err))

Close and remove a dat archive.

multidat.readManifest(dat, callback(err, manifest))

Read the dat.json file from the dat archive. This method is expected to be deprecated once dat archives provide a built-in method to return archives.


This package exists to manage multiple dat archives in different directories. The dat-node package is mostly stateless; all state is persisted into the archives themselves. This package acts as a layer on top to keep track of where archives are located and manage them between sessions.

When not to use this

If you're running a server, it's usually enough to run mafintosh/hypercore-archiver which is more consistent and simpler. If you're building a tool that only needs to manage a single dat archive at the time it's recommended to use datproject/dat-node instead.

See Also