manage dat.json file via toiletdb
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE.md
README.md
index.js
package-lock.json
package.json

README.md

dat-json

read & write dat.json files. Uses toiletdb under the hood.

npm travis standard

Install

npm install dat-json

Usage

var DatJSON = require('dat-json')

var datjson = DatJSON(archive)

datjson.create({title: 'a dat', description: 'exciting'}, function (err) {
  if (err) throw err
})

datjson.read(function (err, data) {
  console.log(data)
})

Write to a dat.json on the file system also:

var DatJSON = require('dat-json')

var datjson = DatJSON(archive, {file: path.join(dat.path, 'dat.json')})

datjson.create({title: 'a dat', description: 'exciting'}, function (err) {
  if (err) throw err
})

TODO: replace file option with hyperdrive indexing

API

var datjson = DatJSON(archive, [opts])

create a new datJson db

Options:

  • opts.file - dat.json file path, updates will be written to file system and archive

datjson.create([data], cb)

Create a new dat.json file in the archive with the default keys (url, title, description). Pass in any additional data to add on initial create.

datjson.write(key, val, cb) or datjson.write(data, cb)

Write a single key and value or an object, data, to the dat.json file. Use file option above to also update the file on the file system.

datjson.delete(key, cb)

Delete a key from the dat.json file.

datjson.read(cb)

Read the current dat.json.

License

MIT