Skip to content

Commit

Permalink
Merge pull request #276 from ForbesLindesay/patch-4
Browse files Browse the repository at this point in the history
Make `Bulk.toString()` actually return a string
  • Loading branch information
saintedlama committed Jan 19, 2016
2 parents ec4e2e9 + e0a4d8d commit 1377b20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bulk.js
Expand Up @@ -138,7 +138,7 @@ Bulk.prototype.tojson = function () {
}

Bulk.prototype.toString = function () {
return this.tojson()
return JSON.stringify(this.tojson())
}

Bulk.prototype.execute = function (cb) {
Expand Down
4 changes: 3 additions & 1 deletion test/test-to-string-bulk.js
@@ -1,6 +1,6 @@
var insert = require('./insert')

insert('bulk to json', [{
insert('bulk to string', [{
name: 'Squirtle', type: 'water'
}, {
name: 'Starmie', type: 'water'
Expand All @@ -20,6 +20,8 @@ insert('bulk to json', [{
bulk.find({ status: 'D' }).removeOne()

var result = bulk.toString()
t.equals(typeof result, 'string', 'bulk.toString() should return a string')
result = JSON.parse(result)
t.equals(result.nInsertOps, 2, 'Should result in nInsertOps field set to 2')
t.equals(result.nUpdateOps, 1, 'Should result in nUpdateOps field set to 1')
t.equals(result.nRemoveOps, 1, 'Should result in nRemoveOps field set to 1')
Expand Down

0 comments on commit 1377b20

Please sign in to comment.