Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @dashevo/dapi-db-eventstore with all npm packages installed. Try it out:

var dapiDbEventstore = require("@dashevo/dapi-db-eventstore")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@dashevo/dapi-db-eventstore v1.4.2

Eventlog for dapi-db

orbit-db-eventstore

npm version

An append-only log with traversable history. Useful for "latest N" use cases or as a message queue.

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 log = orbitdb.eventlog('haad.posts')
log.add({ name: 'hello world' })
  .then(() => {
    const items = log.iterator().collect()
    items.forEach((e) => console.log(e.name))
    // "hello world"
  })

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

const log = orbitdb.eventlog('haad.posts')
log.events.on('ready', () => {
  const items = log.iterator().collect()
  items.forEach((e) => console.log(e.name))
  // "hello world"
})

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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free