stitch_support_v1_update(mongo::ServiceContext::UniqueClient client, mongo::BSONObj updateExpr, mongo::BSONArray arrayFilters, stitch_support_v1_matcher* matcher, stitch_support_v1_collator* collator) : client(std::move(client)), opCtx(this->client->makeOperationContext()), updateExpr(updateExpr.getOwned()), arrayFilters(arrayFilters.getOwned()), matcher(matcher), updateDriver(new mongo::ExpressionContext( opCtx.get(), collator ? collator->collator.get() : nullptr)) { std::vector<mongo::BSONObj> arrayFilterVector; for (auto&& filter : this->arrayFilters) { arrayFilterVector.push_back(filter.embeddedObject()); } this->parsedFilters = uassertStatusOK(mongo::ParsedUpdate::parseArrayFilters( arrayFilterVector, this->opCtx.get(), collator ? collator->collator.get() : nullptr)); // Initializing the update as single-document allows document-replacement updates. bool multi = false; updateDriver.parse(this->updateExpr, parsedFilters, multi); uassert(51037, "Updates with a positional operator require a matcher object.", matcher || !updateDriver.needMatchDetails()); }
stitch_support_v1_matcher(mongo::ServiceContext::UniqueClient client, const mongo::BSONObj& filterBSON, stitch_support_v1_collator* collator) : client(std::move(client)), opCtx(this->client->makeOperationContext()), matcher(filterBSON.getOwned(), new mongo::ExpressionContext(opCtx.get(), collator ? collator->collator.get() : nullptr)){};
stitch_support_v1_projection(mongo::ServiceContext::UniqueClient client, const mongo::BSONObj& pattern, stitch_support_v1_matcher* matcher, stitch_support_v1_collator* collator) : client(std::move(client)), opCtx(this->client->makeOperationContext()), projectionExec(opCtx.get(), pattern.getOwned(), matcher ? matcher->matcher.getMatchExpression() : nullptr, collator ? collator->collator.get() : nullptr), matcher(matcher) { uassert(51050, "Projections with a positional operator require a matcher", matcher || !projectionExec.projectRequiresQueryExpression()); uassert(51051, "$textScore, $sortKey, $recordId, $geoNear and $returnKey are not allowed in this " "context", !projectionExec.hasMetaFields() && !projectionExec.returnKey()); }