https://github.com/adriano-di-giovanni/reaves
A Javascript implementation of the Entity-Attribute-Value model and the event sourcing pattern for Node.js
https://github.com/adriano-di-giovanni/reaves
entity-attribute-value event-sourcing event-store redis
Last synced: 2 months ago
JSON representation
A Javascript implementation of the Entity-Attribute-Value model and the event sourcing pattern for Node.js
- Host: GitHub
- URL: https://github.com/adriano-di-giovanni/reaves
- Owner: adriano-di-giovanni
- License: mit
- Created: 2018-11-09T18:15:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-16T11:01:54.000Z (over 7 years ago)
- Last Synced: 2025-08-09T14:53:07.161Z (10 months ago)
- Topics: entity-attribute-value, event-sourcing, event-store, redis
- Language: JavaScript
- Size: 133 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# reaves
Reaves is a Javascript implementation of the
[Entity-Attribute-Value model](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model) and
the [event sourcing pattern](https://martinfowler.com/eaaDev/EventSourcing.html) for Node.js.
Simply put, it lets you save and retrieve present and past string values of attributes that
belong to entities identified by string IDs. Reaves is backed by [Redis](https://redis.io).
Please, refer to the [Installation](#installation), [Usage](#usage), [API](#api),
[Requirements](#requirements) and [License](#license) sections for more information.
```bash
npm install reaves redis --save
```
```javascript
const { createEntityAttribute, CASE_SENSITIVE, UNIQUE } = require('reaves')
const { generate } = require('randomstring')
const redis = require('redis')
const uuidv4 = require('uuid/v4')
const client = redis.createClient()
const entityName = 'player'
const entityName = 'nickname'
const flags = CASE_SENSITIVE | UNIQUE
createEntityAttribute(client, entityName, attributeName, flags, (err, entityAttribute) => {
if (err) {
throw err
}
const entityId = uuidv4()
const newValue = generate()
const createdAt = Date.now()
entityAttribute.insert(entityId, newValue, createdAt, (err, event) => {
if (err) {
throw err
}
console.log(event)
/*
Event {
entityId: '5eb92392-1d77-4183-858c-7d40a481b914',
value: 'tGxRYYSDxWnbsXSTHcfqXG129IrIjjfd',
createdAt: 1541774323588 }
*/
})
})``
```
## API
Please, refer to the API documentation [here](https://adriano-di-giovanni.github.io/reaves/).
* Node.js 6+
* Redis 2.8.9+
This project is [MIT-licensed](LICENSE)