Skip to content

Commit

Permalink
throw exception if db.put() receives a non-string
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Aug 11, 2010
1 parent 78dadb8 commit 8d3fd1f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/cradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ cradle.Connection.prototype.database = function (name) {

put: function (id, doc) {
var cache = this.cache, args = new(Args)(arguments);
if (typeof(id) !== 'string') { throw new(TypeError)("id must be a string") }
return this.query('PUT', id, null, doc).addCallback(function (e, res) {
if (! e) cache.save(id, cradle.merge({}, doc, { _rev: res.rev }));
args.callback(e, res);
Expand Down

0 comments on commit 8d3fd1f

Please sign in to comment.