https://github.com/orbitdb-archive/orbit-db-eventstore
Append-Only Log database for orbit-db
https://github.com/orbitdb-archive/orbit-db-eventstore
eventstore log-database orbit-db orbitdb
Last synced: about 1 year ago
JSON representation
Append-Only Log database for orbit-db
- Host: GitHub
- URL: https://github.com/orbitdb-archive/orbit-db-eventstore
- Owner: orbitdb-archive
- License: mit
- Archived: true
- Created: 2016-05-07T08:27:18.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-01-18T23:10:15.000Z (over 3 years ago)
- Last Synced: 2024-11-04T19:42:03.990Z (over 1 year ago)
- Topics: eventstore, log-database, orbit-db, orbitdb
- Language: JavaScript
- Homepage:
- Size: 927 KB
- Stars: 30
- Watchers: 7
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - orbitdb-archive/orbit-db-eventstore - Append-Only Log database for orbit-db (JavaScript)
README
# orbit-db-eventstore
[](https://badge.fury.io/js/orbit-db-eventstore)
[](https://gitter.im/orbitdb/Lobby) [](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io)
> Append-Only Log database for orbit-db
An append-only log with traversable history. Useful for *"latest N"* use cases or as a message queue.
Used in [orbit-db](https://github.com/haadcode/orbit-db).
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contributing](#contributing)
- [License](#license)
## Install
This project uses [npm](https://npmjs.com) and [nodejs](https://nodejs.org)
```sh
npm install orbit-db ipfs
```
## Usage
First, create an instance of OrbitDB:
```javascript
import * as IPFS from 'ipfs'
import OrbitDB from 'orbit-db'
const ipfs = new IPFS()
const orbitdb = await OrbitDB.createInstance(ipfs)
```
Get a log database and add an entry to it:
```javascript
const log = await orbitdb.eventlog('haad.posts')
log.add({ name: 'hello world' })
.then(() => {
const items = log.iterator().collect().map(e => e.payload.value)
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 = await orbitdb.eventlog('haad.posts')
log.events.on('ready', () => {
const items = log.iterator().collect().map(e => e.payload.value)
items.forEach(e => console.log(e.name))
// "hello world"
})
```
See [example/index.html](https://github.com/haadcode/orbit-db-eventstore/blob/master/example/index.html) for a detailed example. Note that to run this example, you need to have a local [IPFS daemon](https://dist.ipfs.io/go-ipfs/floodsub-2) [running](https://ipfs.io/docs/getting-started/) at port 5001.
## API
See [orbit-db's API Documenations](https://github.com/haadcode/orbit-db/blob/master/API.md#eventlogname) for full details.
## Contributing
If you think this could be better, please [open an issue](https://github.com/orbitdb/orbit-db-eventstore/issues/new)!
Please note that all interactions in @orbitdb fall under our [Code of Conduct](CODE_OF_CONDUCT.md).
Note that tests for this module are in the [`orbit-db`](https://github.com/orbitdb/orbit-db) repository.
## License
[MIT](LICENSE) © 2016-2020 Protocol Labs Inc., Haja Networks Oy