summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/mozjs/mongo.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-07-10 16:52:49 -0400
committerMathias Stearn <mathias@10gen.com>2017-07-26 15:13:34 -0400
commitc731446ad3cc399d33b5b2cb28e5b776580f1beb (patch)
tree13be492fa9b16ed3d9e296d4d42e9fa2598cfad4 /src/mongo/scripting/mozjs/mongo.cpp
parent191931c4390ab1ede373e6772aa4d3999518fdaf (diff)
downloadmongo-c731446ad3cc399d33b5b2cb28e5b776580f1beb.tar.gz
SERVER-28509 Make DBClient use write commands
Everything that needs to actually use legacy write ops now does so explicitly.
Diffstat (limited to 'src/mongo/scripting/mozjs/mongo.cpp')
-rw-r--r--src/mongo/scripting/mozjs/mongo.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/scripting/mozjs/mongo.cpp b/src/mongo/scripting/mozjs/mongo.cpp
index 1c22e4e5e27..551c56f44a3 100644
--- a/src/mongo/scripting/mozjs/mongo.cpp
+++ b/src/mongo/scripting/mozjs/mongo.cpp
@@ -337,6 +337,7 @@ void MongoBase::Functions::insert::call(JSContext* cx, JS::CallArgs args) {
return ValueWriter(cx, value).toBSON();
};
+ Message toSend;
if (args.get(1).isObject()) {
bool isArray;
@@ -366,14 +367,17 @@ void MongoBase::Functions::insert::call(JSContext* cx, JS::CallArgs args) {
if (!foundElement)
uasserted(ErrorCodes::BadValue, "attempted to insert an empty array");
- conn->insert(ns, bos, flags);
+ toSend = makeInsertMessage(ns, bos.data(), bos.size(), flags);
} else {
- conn->insert(ns, addId(args.get(1)));
+ toSend = makeInsertMessage(ns, addId(args.get(1)));
}
} else {
- conn->insert(ns, addId(args.get(1)));
+ toSend = makeInsertMessage(ns, addId(args.get(1)));
}
+ invariant(!toSend.empty());
+ conn->say(toSend);
+
args.rval().setUndefined();
}
@@ -399,7 +403,8 @@ void MongoBase::Functions::remove::call(JSContext* cx, JS::CallArgs args) {
justOne = args.get(2).toBoolean();
}
- conn->remove(ns, bson, justOne);
+ auto toSend = makeRemoveMessage(ns, bson, justOne ? RemoveOption_JustOne : 0);
+ conn->say(toSend);
args.rval().setUndefined();
}
@@ -427,7 +432,9 @@ void MongoBase::Functions::update::call(JSContext* cx, JS::CallArgs args) {
bool upsert = args.length() > 3 && args.get(3).isBoolean() && args.get(3).toBoolean();
bool multi = args.length() > 4 && args.get(4).isBoolean() && args.get(4).toBoolean();
- conn->update(ns, q1, o1, upsert, multi);
+ auto toSend = makeUpdateMessage(
+ ns, q1, o1, (upsert ? UpdateOption_Upsert : 0) | (multi ? UpdateOption_Multi : 0));
+ conn->say(toSend);
args.rval().setUndefined();
}