summaryrefslogtreecommitdiff
path: root/src/mongo/shell/crud_api.js
diff options
context:
space:
mode:
authorMatt Cotter <matt.cotter@mongodb.com>2016-09-06 12:57:16 -0400
committerMatt Cotter <matt.cotter@mongodb.com>2016-09-13 11:22:36 -0400
commitcbbb6730683a8ef3620061a5a3a74da85460f501 (patch)
tree9c86c2f1fd086c3dba31a7101764a23c55553585 /src/mongo/shell/crud_api.js
parentfec08a992e29f9b0a9a227602b040987d17a940e (diff)
downloadmongo-cbbb6730683a8ef3620061a5a3a74da85460f501.tar.gz
SERVER-23936 insertOne only accepts objects
Diffstat (limited to 'src/mongo/shell/crud_api.js')
-rw-r--r--src/mongo/shell/crud_api.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/shell/crud_api.js b/src/mongo/shell/crud_api.js
index dafbb10510d..e9678cad16a 100644
--- a/src/mongo/shell/crud_api.js
+++ b/src/mongo/shell/crud_api.js
@@ -27,12 +27,17 @@ DBCollection.prototype._createWriteConcern = function(options) {
* Otherwise, returns the same object passed.
*/
DBCollection.prototype.addIdIfNeeded = function(obj) {
+ if (typeof obj !== "object") {
+ throw new Error('argument passed to addIdIfNeeded is not an object');
+ }
if (typeof(obj._id) == "undefined" && !Array.isArray(obj)) {
var tmp = obj; // don't want to modify input
obj = {_id: new ObjectId()};
for (var key in tmp) {
- obj[key] = tmp[key];
+ if (tmp.hasOwnProperty(key)) {
+ obj[key] = tmp[key];
+ }
}
}