dweb-json

1.0.0 • Public • Published

dweb-json

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

npm travis standard

Install

npm install dweb-json

Usage

var DatJSON = require('dweb-json')
 
var datjson = DatJSON(archive)
 
datjson.create({title: 'a dweb', description: 'exciting'}, function (err) {
  if (err) throw err
})
 
datjson.read(function (err, data) {
  console.log(data)
})

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

var DatJSON = require('dweb-json')
 
var datjson = DatJSON(archive, {file: path.join(dweb.path, 'dweb.json')})
 
datjson.create({title: 'a dweb', description: 'exciting'}, function (err) {
  if (err) throw err
})

TODO: replace file option with dwebfs indexing

API

var datjson = DatJSON(archive, [opts])

create a new datJson db

Options:

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

datjson.create([data], cb)

Create a new dweb.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 dweb.json file. Use file option above to also update the file on the file system.

datjson.delete(key, cb)

Delete a key from the dweb.json file.

datjson.read(cb)

Read the current dweb.json.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i dweb-json

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

8.22 kB

Total Files

5

Last publish

Collaborators

  • shikhars3711