Skip to content

Instantly share code, notes, and snippets.

@adriano-di-giovanni
Created November 10, 2018 18:56
Show Gist options
  • Save adriano-di-giovanni/4ee90431ef5fb0d741cddf08df0e57b2 to your computer and use it in GitHub Desktop.
Save adriano-di-giovanni/4ee90431ef5fb0d741cddf08df0e57b2 to your computer and use it in GitHub Desktop.
const { createEntityAttribute, CASE_SENSITIVE, NULLABLE, UNIQUE } = require('reaves')
const { generate } = require('randomstring')
const redis = require('redis')
const uuidv4 = require('uuid/v4')
const client = redis.createClient()
const entityName = 'player'
const attributeName = 'nickname'
const flags = CASE_SENSITIVE | NULLABLE | UNIQUE
createEntityAttribute(client, entityName, attributeName, flags, (err, playerNickname) => {
if (err) {
throw err
}
const entityId = uuidv4()
const newValue = generate()
const createdAt = Date.now()
playerNickname.insert(entityId, newValue, createdAt, console.log.bind(console))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment