From 9609d71d3eec70f30cedb52573e65dea8bf8416f Mon Sep 17 00:00:00 2001 From: vaultec <47548474+vaultec81@users.noreply.github.com> Date: Mon, 11 May 2020 16:55:32 -0700 Subject: [PATCH] Add append event support (#34) * Add append event support * Latest orbit-db-store version. --- package.json | 4 ++-- src/EventStore.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4b42533..5e158dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orbit-db-eventstore", - "version": "1.8.0", + "version": "1.9.0", "description": "Eventlog for orbit-db", "main": "src/EventStore.js", "homepage": "https://github.com/orbitdb/orbit-db-eventstore", @@ -21,7 +21,7 @@ "author": "Haad", "license": "MIT", "dependencies": { - "orbit-db-store": "~3.1.0" + "orbit-db-store": "~3.3.0" }, "devDependencies": { "standard": "^12.0.1" diff --git a/src/EventStore.js b/src/EventStore.js index 8d4ee98..8bd003d 100644 --- a/src/EventStore.js +++ b/src/EventStore.js @@ -9,7 +9,10 @@ class EventStore extends Store { constructor (ipfs, id, dbname, options = {}) { if (options.Index === undefined) Object.assign(options, { Index: EventIndex }) super(ipfs, id, dbname, options) - this._type = 'eventlog' + this._type = 'eventlog'; + this.events.on("log.op.ADD", (address, hash, payload) => { + this.events.emit("db.append", payload.value) + }) } add (data, options = {}) { @@ -23,7 +26,6 @@ class EventStore extends Store { get (hash) { return this.iterator({ gte: hash, limit: 1 }).collect()[0] } - iterator (options) { const messages = this._query(options) let currentIndex = 0