@dashevo/dapi-db-counterstore

1.4.2 • Public • Published

orbit-db-counterstore

npm version

A simple counters database. Useful for example counting events separate from data.

Used in orbit-db.

Table of Contents

Install

npm install orbit-db ipfs

Usage

First, create an instance of OrbitDB:

const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')

const ipfs = new IPFS()
const orbitdb = new OrbitDB(ipfs)

Get a log database and add an entry to it:

const counter = orbitdb.counter('visitors')
counter.inc()
console.log(counter.value)
// 1
counter.inc(4)
console.log(counter.value)
// 5

Later, when the database contains data, load the history and query when ready:

const counter = orbitdb.counter('visitors')
counter.events.on('ready', () => {
  counter.inc()
  console.log(counter.value)
  // 6
})

See example/index.html for a detailed example. Note that to run this example, you need to have a local IPFS daemon running at port 5001.

API

See orbit-db's API Documenations for full details.

Contributing

See orbit-db's contributing guideline.

License

MIT © 2016-2018 Protocol Labs Inc., Haja Networks Oy, 2018 Dash Core Group, Inc.

Readme

Keywords

none

Package Sidebar

Install

npm i @dashevo/dapi-db-counterstore

Weekly Downloads

0

Version

1.4.2

License

MIT

Unpacked Size

1.27 MB

Total Files

10

Last publish

Collaborators

  • shumkov
  • alex-werner
  • nmarley
  • cofresi
  • antouhou
  • evodeploy
  • jawid-h