firebase-event-store
A basic multi-tenant event sourcing library using firestore to record aggregates, events, and documents (read model)
Installation
npm install firebase-event-store
Usage
const Aggregate Command Evento FirestoreEventStore Bus ERRORS } = const firestoreDb = //TODO init firesore dbconst evtStore = firestoreDbconst bus = evtStorebus { if !_number1 throw ERRORS if !_number2 throw ERRORS thisnumber1 = _number1 thisnumber2 = _number2 } { super thissum = 0 } { return '/calculators' } async { } { } { super thisdb = db } { const path = '/counters/counter1' if eventeventName === NumbersAddedname let snap = await thisdb let doc = snapdata || {} doceventCount = doceventCount || 0 + 1 return await thisdb } let actor = id: 'user1' tenant: 'tenant1' let calc = await buscalc = await busconsole
Tests
npm test
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.