dat-folder-db
v2.1.3
Published
create .dat folders compatible with the dat CLI
Readme
dat-folder-db

Make Dat CLI compatible databases. A database made with dat-folder-db can be resumed with the Dat CLI.
Wrapper of level to create/resume a .dat folder database. If there is an existing .dat folder, it will get the key of the existing dat, allowing it to be resumed.
Use in Dat applications using node and the file system to store the database.
Usage
var datDb = require('dat-folder-db')
datDb(dir, function (err, db, existingKey, putKey) {
if (err) throw err
var resume = !!existingKey // resume the dat if a key exists
// use db with hyperdrive
var drive = hyperdrive(db)
var archive = drive.createArchive(existingKey)
if (!resume) putkey(archive.key, function () {
// key in db. can resume now
})
})This will create a .dat folder: my_folder/.dat and a level database in that folder.
See example.js for a full example.
API
datFolder(dir, [opts], cb)
Creates a level db in the .dat folder and checks if there is an existing key saved there.
diris required. This is the base path for the dat folder.cbis called with(err, db, existingKey, saveKey)dbis the level database indir/.datexistingKeyis the key found in the database or null if nothing is found.saveKeyis a function to save the key back to the database.
opts include:
opts = {
dbName : '.dat' // use a different name for the database
}License
MIT
