reaves

0.2.1 • Public • Published

reaves

Reaves is a Javascript implementation of the Entity-Attribute-Value model and the event sourcing pattern 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.

Please, refer to the Installation, Usage, API, Requirements and License sections for more information.

Installation

npm install reaves redis --save

Usage

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.

Requirements

  • Node.js 6+
  • Redis 2.8.9+

License

This project is MIT-licensed

Package Sidebar

Install

npm i reaves

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

741 kB

Total Files

158

Last publish

Collaborators

  • adigiovanni