/dwebx-json

DEPRECATED LEGACY DWEB MODULE

Primary LanguageJavaScriptMIT LicenseMIT

dwebx-json

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

npm travis standard

Install

npm install dwebx-json

Usage

var DWebxJSON = require('dwebx-json')

var dwebxjson = DWebxJSON(archive)

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

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

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

var DWebxJSON = require('dwebx-json')

var dwebxjson = DWebxJSON(archive, {file: path.join(dwebx.path, 'dwebx.json')})

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

TODO: replace file option with ddrive indexing

API

var dwebxjson = DWebxJSON(archive, [opts])

create a new dwebxJson db

Options:

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

dwebxjson.create([data], cb)

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

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

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

dwebxjson.delete(key, cb)

Delete a key from the dwebx.json file.

dwebxjson.read(cb)

Read the current dwebx.json.

License

MIT