diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-02-10 19:51:31 -0500 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-02-18 19:12:42 -0500 |
commit | 25c2e4bcb4d25fddf0eb2b214ff9229f26456b89 (patch) | |
tree | 33cdd86dfbb34573f99abad0b53a8eaa513d4663 /src/mongo/shell/bulk_api.js | |
parent | efc9a4a324fa7046be9ec41431c3edf6f9be24ef (diff) | |
download | mongo-25c2e4bcb4d25fddf0eb2b214ff9229f26456b89.tar.gz |
SERVER-12668 shell reporting of w:0 write results is ugly
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Diffstat (limited to 'src/mongo/shell/bulk_api.js')
-rw-r--r-- | src/mongo/shell/bulk_api.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mongo/shell/bulk_api.js b/src/mongo/shell/bulk_api.js index 1d87404b7ad..21c5ce1e232 100644 --- a/src/mongo/shell/bulk_api.js +++ b/src/mongo/shell/bulk_api.js @@ -59,7 +59,7 @@ var _bulk_api_module = (function() { * singleBatch is passed in on bulk operations consisting of a single batch and * are used to filter the SingleWriteResult to only include relevant result fields. */ - var SingleWriteResult = function(bulkResult, singleBatch) { + var SingleWriteResult = function(bulkResult, singleBatch, writeConcern) { // Define properties defineReadOnlyProperty(this, "ok", bulkResult.ok); defineReadOnlyProperty(this, "nInserted", bulkResult.nInserted); @@ -137,11 +137,15 @@ var _bulk_api_module = (function() { }; this.toString = function() { - return this.tojson(); + // Suppress all output for the write concern w:0, since the client doesn't care. + if(writeConcern && writeConcern.w == 0) { + return "WriteResult(" + tojson({}) + ")";; + } + return "WriteResult(" + this.tojson() + ")"; }; this.shellPrint = function() { - return "WriteResult(" + this.toString() + ")"; + return this.toString(); }; this.isOK = function() { @@ -152,7 +156,7 @@ var _bulk_api_module = (function() { /** * Wraps the result for the commands */ - var BulkWriteResult = function(bulkResult, singleBatch) { + var BulkWriteResult = function(bulkResult, singleBatch, writeConcern) { // Define properties defineReadOnlyProperty(this, "ok", bulkResult.ok); defineReadOnlyProperty(this, "nInserted", bulkResult.nInserted); @@ -227,7 +231,11 @@ var _bulk_api_module = (function() { } this.toString = function() { - return "BulkWriteResult(" + tojson(bulkResult) + ")"; + // Suppress all output for the write concern w:0, since the client doesn't care. + if(writeConcern && writeConcern.w == 0) { + return "BulkWriteResult(" + tojson({}) + ")";; + } + return "BulkWriteResult(" + this.tojson() + ")"; } this.shellPrint = function() { @@ -244,7 +252,7 @@ var _bulk_api_module = (function() { this.toSingleResult = function() { if(singleBatch == null) throw Error( "Cannot output SingleWriteResult from multiple batch result"); - return new SingleWriteResult(bulkResult, singleBatch); + return new SingleWriteResult(bulkResult, singleBatch, writeConcern); } }; @@ -924,11 +932,11 @@ var _bulk_api_module = (function() { executed = true; if(batches.length == 1) { - return new BulkWriteResult(bulkResult, batches[0]); + return new BulkWriteResult(bulkResult, batches[0], writeConcern); } // Execute the batch and return the final results - return new BulkWriteResult(bulkResult); + return new BulkWriteResult(bulkResult, null, writeConcern); } } })(); @@ -1003,4 +1011,4 @@ if ( ( typeof WriteConcern ) == 'undefined' ){ WriteConcern.prototype.shellPrint = function() { return this.toString(); }; -}
\ No newline at end of file +} |