![Gitter](https://badges.gitter.im/Join Chat.svg)
A nodejs client library for (Get) Event Store
Want to help out? Check out a waiting issue
This client assumes that you already have an Event Store instance running.
Install
$ npm install ges-client
Append and read from an event stream
var ges = require('ges-client')
// 1) Create a connection to a running EventStore
// using default connection options and credentials
var connection = ges()
, stream = 'intro-events'
// 2) Append events that can be read
connection.on('connect', function() {
var appendData = {
expectedVersion: ges.expectedVersion.emptyStream
, events: [array of events]
}
connection.appendToStream(stream, appendData, function(err, appendResult) {
if(err) return console.log('Ooops!', err) // connection error
// 3) Read first events from the stream
connection.readStreamEventsForward(stream, { start: 0, count: 1 }, function(err, readResult) {
if(err) return console.log('Ooops!', err) // connection error or stream does not exist
// ta da!
console.log(readResult.Events)
})
})
})
Subscribe to stream updates
var ges = require('ges-client')
// 1) Create a connection to a running EventStore
// using default connection options and credentials
var connection = ges()
, stream = 'intro-events'
// 2) Create a subscription
connection.on('connect', function() {
var subscription = connection.subscribeToStream(stream)
// 3) Listen for events
subscription.on('event', function(evt) {
// ta da!
console.log(evt)
})
var appendData = {
expectedVersion: ges.expectedVersion.emptyStream
, events: [array of events]
}
connection.appendToStream(stream, appendData, function(err, appendResult) {
if(err) return console.log('Ooops!', err) // connection error
})
})
- Connection (Partial - not all events are available)
- Append to stream (Complete)
- Read from stream (Complete)
- Subscriptions (Complete)
- Read from all (Complete)
- Stream ACLs (Not Started)
- Transactions (Complete)
- Stream deletes (Complete)
- Stream metadata (Complete)
Copyright (c) 2014 Brian Mavity.
ges-client is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
Special thanks to Ken Pratt for writing the first version of this over at https://github.com/kenpratt/nodejs-EventStore . It made early development go by much faster.