summaryrefslogtreecommitdiff
path: root/src/mongo/scripting
diff options
context:
space:
mode:
authorIrina Yatsenko <irina.yatsenko@mongodb.com>2021-08-16 15:35:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-23 19:44:53 +0000
commitdf329d8f46e1485dd5d70379f9c48bf4175f0d5a (patch)
tree80adf0442b021bdd689d59697a6b85ebf4dab24d /src/mongo/scripting
parent5cf8a293567989fcc970fb21cde4a1af111c8b58 (diff)
downloadmongo-df329d8f46e1485dd5d70379f9c48bf4175f0d5a.tar.gz
SERVER-58670 Tighten up what kind of BSON the 'Query' type can be wrapped around
This refactor includes: Remove dead code from 'Query' type and reduce it public interface. Split query argument in query/update/removed methods into filter BSON and settings (which are still passed around as 'Query' type). Remove Query(string) constructors. Remove most callers of 'Query(const BSONObj&)'. Replace public 'Query(const BSON&)' and 'Query.obj' with an explicit factory method and a getter.
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r--src/mongo/scripting/engine.cpp2
-rw-r--r--src/mongo/scripting/mozjs/mongo.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index 09e40facbbf..397adff2a76 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -233,7 +233,7 @@ void Scope::loadStored(OperationContext* opCtx, bool ignoreNotConnected) {
auto directDBClient = DBDirectClientFactory::get(opCtx).create(opCtx);
unique_ptr<DBClientCursor> c =
- directDBClient->query(coll, Query(), 0, 0, nullptr, QueryOption_SecondaryOk, 0);
+ directDBClient->query(coll, BSONObj{}, Query(), 0, 0, nullptr, QueryOption_SecondaryOk, 0);
massert(16669, "unable to get db client cursor from query", c.get());
set<string> thisTime;
diff --git a/src/mongo/scripting/mozjs/mongo.cpp b/src/mongo/scripting/mozjs/mongo.cpp
index 9a27f8a5e44..a850a7a9d1a 100644
--- a/src/mongo/scripting/mozjs/mongo.cpp
+++ b/src/mongo/scripting/mozjs/mongo.cpp
@@ -367,8 +367,10 @@ void MongoBase::Functions::find::call(JSContext* cx, JS::CallArgs args) {
int batchSize = ValueWriter(cx, args.get(5)).toInt32();
int options = ValueWriter(cx, args.get(6)).toInt32();
+ const Query query = Query::fromBSONDeprecated(q);
std::unique_ptr<DBClientCursor> cursor(conn->query(NamespaceString(ns),
- q,
+ query.getFilter(),
+ query,
limit,
nToSkip,
haveFields ? &fields : nullptr,