Skip to content

Commit

Permalink
added dynamic key mapper for retrieving multiple values from the same…
Browse files Browse the repository at this point in the history
… dynamic key
  • Loading branch information
Radagaisus committed Jan 3, 2014
1 parent 81d1d83 commit e7b9da6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
8 changes: 1 addition & 7 deletions dist/commands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 27 additions & 14 deletions dist/orpheus.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions lib/orpheus.coffee
Expand Up @@ -415,6 +415,7 @@ class OrpheusAPI
@_res_schema.push
type: type
name: key
dynamic_key_args: dynamic_key_args
with_scores: type is 'zset' and 'withscores' in args

# Run validation, if needed
Expand Down Expand Up @@ -581,10 +582,19 @@ class OrpheusAPI
if new_res[s.name]?
# We use temp_res as a temporary storage for
# the multiple results array.
if temp_res[s.name]?
temp_res[s.name].push res[i]

if @model[s.name].options.key

temp_res[s.name] ||= {}
dynamic_key = @model[s.name].options.key.apply(this, s.dynamic_key_args)
temp_res[s.name][dynamic_key] = res[i]

else
temp_res[s.name] = [new_res[s.name], res[i]]

if temp_res[s.name]?
temp_res[s.name].push res[i]
else
temp_res[s.name] = [new_res[s.name], res[i]]

new_res[s.name] = temp_res[s.name]
else
Expand Down

0 comments on commit e7b9da6

Please sign in to comment.