summaryrefslogtreecommitdiff
path: root/src/mongo/shell/bulk_api.js
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-04-25 17:55:54 -0400
committerDavid Storch <david.storch@10gen.com>2016-05-10 09:16:34 -0400
commit6218a59683bf97c6cb7f198f9d9eccc0371f8bb7 (patch)
treeea0558dec72853193d406a0eb2942fff850c4f57 /src/mongo/shell/bulk_api.js
parente381d56bfe3a805e44678566437ef4a732d3fa1a (diff)
downloadmongo-6218a59683bf97c6cb7f198f9d9eccc0371f8bb7.tar.gz
SERVER-23791 extend shell helpers to pass collation parameter to server
Includes changes to the following: - Bulk API - CRUD API - DBCollection CRUD methods (e.g. DBCollection.prototype.remove()) - New DBQuery.prototype.collation() method to use with find().
Diffstat (limited to 'src/mongo/shell/bulk_api.js')
-rw-r--r--src/mongo/shell/bulk_api.js37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/mongo/shell/bulk_api.js b/src/mongo/shell/bulk_api.js
index 84dc583b1ea..8ef10b5c976 100644
--- a/src/mongo/shell/bulk_api.js
+++ b/src/mongo/shell/bulk_api.js
@@ -674,6 +674,11 @@ var _bulk_api_module = (function() {
upsert: upsert
};
+ // Copy over the collation, if we have one.
+ if (currentOp.hasOwnProperty('collation')) {
+ document.collation = currentOp.collation;
+ }
+
// Clear out current Op
currentOp = null;
// Add the update document to the list
@@ -693,6 +698,11 @@ var _bulk_api_module = (function() {
upsert: upsert
};
+ // Copy over the collation, if we have one.
+ if (currentOp.hasOwnProperty('collation')) {
+ document.collation = currentOp.collation;
+ }
+
// Clear out current Op
currentOp = null;
// Add the update document to the list
@@ -718,6 +728,11 @@ var _bulk_api_module = (function() {
limit: 1
};
+ // Copy over the collation, if we have one.
+ if (currentOp.hasOwnProperty('collation')) {
+ document.collation = currentOp.collation;
+ }
+
// Clear out current Op
currentOp = null;
// Add the remove document to the list
@@ -733,11 +748,31 @@ var _bulk_api_module = (function() {
limit: 0
};
+ // Copy over the collation, if we have one.
+ if (currentOp.hasOwnProperty('collation')) {
+ document.collation = currentOp.collation;
+ }
+
// Clear out current Op
currentOp = null;
// Add the remove document to the list
return addToOperationsList(REMOVE, document);
- }
+ },
+
+ collation: function(collationSpec) {
+ if (!collection.getMongo().hasWriteCommands()) {
+ throw new Error(
+ "cannot use collation if server does not support write commands");
+ }
+
+ if (collection.getMongo().writeMode() !== "commands") {
+ throw new Error("write mode must be 'commands' in order to use collation, " +
+ "but found write mode: " + collection.getMongo().writeMode());
+ }
+
+ currentOp.collation = collationSpec;
+ return findOperations;
+ },
};
//