Skip to content

Commit

Permalink
Merge pull request #15 from Radagaisus/update/14
Browse files Browse the repository at this point in the history
Updated the commands getters and type lists with new Redis commands
  • Loading branch information
Radagaisus committed May 6, 2015
2 parents cb8fb4f + 6385f41 commit 45dc9d6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
73 changes: 39 additions & 34 deletions lib/commands.coffee
@@ -1,31 +1,25 @@
# Redis Commands
#-------------------------------------#
# ------------------------------------------------------------------------------------
module.exports =
validations:
# String
hsetnx: true
hset: true

# Number
hincrby: true
hincrbyfloat: true

# List
lpush: true # several values, 1
lpushx: true
rpush: true # several values, 1
rpushx: true

# Set
sadd: true # several values, 1

# Zset
zadd: true # several values, reverted, 2
zincrby: true # reverted

# Hash
hmset: true # several values, 2

# Validations does not support:
# - zinterstore
# - zunionstore
Expand All @@ -38,48 +32,50 @@ module.exports =
# - brpoplpush and friends

getters: [

# List
'lrange',
'llen',

# Set
'smembers',
'scard',

# Zset
'zcard',
'zcount',
'zlexcount',
'zrange',
'zrangebylex',
'zrevrangebylex',
'zrangebyscore',
'zrank',
'zrevrange',
'zrevrangebyscore',
'zscore',
'zrank',
'zrevrank',
'zcount',
'zcard',

'zscore',
# Hash, String, Number
'hget',
'hgetall',
'hmget'
'hmget',
'hstrlen'
]

str: [
'hdel',
'hexists',
'hget',
'hset',
'hsetnx',
'hset'
'hstrlen'
]

num: [
'hdel',
'hexists',
'hget',
'hsetnx',
'hset',
'hincrby',
'hincrbyfloat'
'hincrbyfloat',
'hset',
'hsetnx',
'hstrlen'
]

list: [
Expand Down Expand Up @@ -116,7 +112,8 @@ module.exports =
'srandmember',
'srem',
'sunion',
'sunionstore'
'sunionstore',
'sscan'
]

zset: [
Expand All @@ -125,17 +122,22 @@ module.exports =
'zcount',
'zincrby',
'zinterstore',
'zlexcount',
'zrange',
'zrangebylex',
'zrevrangebylex',
'zrangebyscore',
'zrank',
'zrem',
'zremrangebylex',
'zremrangebyrank',
'zremrangebyscore',
'zrevrange',
'zrevrangebyscore',
'zrevrank',
'zscore',
'zunionstore'
'zunionstore',
'zscan'
]

hash: [
Expand All @@ -156,16 +158,20 @@ module.exports =

# Operations that can be called on zset, set, hash and list attributes
keys: [
'type'
'ttl'
'del'
'dump'
'exists'
'expire'
'expireat'
'persist'
'pexpire'
'pexpireat'
'pttl'
'persist'
'expireat'
'expire'
'exists'
'del'
'restore'
'sort'
'ttl'
'type'
'scan'
]

shorthands:
Expand All @@ -176,14 +182,12 @@ module.exports =
zset: 'z'
hash: 'h'

# This maps commands for the add(),
# set() and delete() functions.
# Adding in a set results in sadd,
# deleting a num is hdel, etc.
# This maps commands for the `add()`, `set()` and `delete()` functions. Adding in a set
# results in `sadd`, deleting a number is `hdel`, etc.
command_map:
add:
num: 'hincrby'
str: 'hset' # we don't 'optimize' with hmset
str: 'hset' # We don't 'optimize' with hmset
set: 'sadd'
zset: 'zincrby'
list: 'lpush'
Expand All @@ -194,3 +198,4 @@ module.exports =
set: 'sadd'
zset: 'zadd'
list: 'lpush'

4 changes: 2 additions & 2 deletions test/orpheus.spec.coffee
Expand Up @@ -78,7 +78,7 @@ describe 'Error Handling', ->
# --------------------------------------------------------------------------
describe 'Raw Responses', ->

it 'returns a raw response', (done) ->
it 'Returns a raw response', (done) ->
class App extends Orpheus
constructor: ->
@zset 'leaderboard'
Expand All @@ -102,7 +102,7 @@ describe 'Raw Responses', ->
# ------------------------------------------------------------------------------
describe 'Schema', ->

it 'can call the different models using the schema', (done) ->
it 'Can call the different models using the schema', (done) ->
class Hello extends Orpheus
constructor: ->
@str 'name'
Expand Down

0 comments on commit 45dc9d6

Please sign in to comment.