Skip to content
Browse files

Add database option support to DB.append

  • Loading branch information...
1 parent 326c1b5 commit 4422fb89092929d1d5d5153698d416e140b65eed @wezm committed Apr 4, 2011
Showing with 17 additions and 6 deletions.
  1. +7 −6 src/db.coffee
  2. +10 −0 test/db_test.coffee
View
13 src/db.coffee
@@ -173,17 +173,18 @@ class DB
append: (key, value, 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 append");
- rpc_args =
- key: key
- value: value
- rpc_args.DB = database if database?
+ rpc_args = this._initRpcArgs options
+ rpc_args.key = key
+ rpc_args.value = value
@rpcClient.call 'append', rpc_args, (error, status, output) ->
if error?
callback error, output
View
10 test/db_test.coffee
@@ -183,6 +183,16 @@ module.exports =
test.equal value, "Value"
test.done()
+ 'allows the database to be specified': (test) ->
+ test.expect 2
+ db.append 'test', 'other db', {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()
+
increment: testCase
setUp: dbClear

0 comments on commit 4422fb8

Please sign in to comment.
Something went wrong with that request. Please try again.