Skip to content

Commit

Permalink
Add database option support to DB.append
Browse files Browse the repository at this point in the history
  • Loading branch information
wezm committed Apr 4, 2011
1 parent 326c1b5 commit 4422fb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/db.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/db_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4422fb8

Please sign in to comment.