Eventlog for dapi-db
npm install @dashevo/dapi-db-eventstore
An append-only log with traversable history. Useful for "latest N" use cases or as a message queue.
Used in orbit-db.
- Install
- Usage
- API
- Contributing
- License
npm install orbit-db ipfs
`Usage
First, create an instance of OrbitDB:
`javascript
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:
`javascript
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:
`javascript
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.
See orbit-db's API Documenations for full details.
See orbit-db's contributing guideline.
MIT © 2016-2018 Protocol Labs Inc., Haja Networks Oy, 2018 Dash Core Group, Inc.