Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add database option support to DB.incrementDouble

  • Loading branch information...
commit 35e630e6c0307d1730f87bae6b67a660dd4f7ef0 1 parent b50fbe4
Wesley Moore authored
Showing with 17 additions and 6 deletions.
  1. +7 −6 src/db.coffee
  2. +10 −0 test/db_test.coffee
13 src/db.coffee
View
@@ -220,17 +220,18 @@ class DB
incrementDouble: (key, num, args...) ->
switch args.length
- when 1 then callback = args[0]
+ when 1
+ options = {}
+ callback = args[0]
when 2
- database = args[0]
+ options = args[0]
callback = args[1]
else
throw new Error("Invalid number of arguments (#{args.length}) to incrementDouble");
- rpc_args =
- key: key
- num: num
- rpc_args.DB = database if database?
+ rpc_args = this._initRpcArgs options
+ rpc_args.key = key
+ rpc_args.num = num
@rpcClient.call 'increment_double', rpc_args, (error, status, output) ->
if error?
callback error, output
10 test/db_test.coffee
View
@@ -255,6 +255,16 @@ module.exports =
test.ok error?
test.done()
+ 'allows the database to be specified': (test) ->
+ test.expect 2
+ db.incrementDouble 'test', 1.89, {database: 'test2.kct'}, (error, output) ->
+ test.ifError error
+
+ # Check that the value wasn't set on the default db
+ db.get 'test', (error, value) ->
+ test.ok value == null
+ test.done()
+
cas: testCase
setUp: dbClear
Please sign in to comment.
Something went wrong with that request. Please try again.