void OrMatchExpression::serialize(BSONObjBuilder* out) const { if (!numChildren()) { out->append(AlwaysFalseMatchExpression::kName, 1); return; } BSONArrayBuilder arrBob(out->subarrayStart("$or")); _listToBSON(&arrBob); }
void AndMatchExpression::serialize(BSONObjBuilder* out) const { if (!numChildren()) { // It is possible for an AndMatchExpression to have no children, resulting in the serialized // expression {$and: []}, which is not a valid query object. return; } BSONArrayBuilder arrBob(out->subarrayStart("$and")); _listToBSON(&arrBob); arrBob.doneFast(); }
void OrMatchExpression::serialize(BSONObjBuilder* out) const { if (!numChildren()) { // It is possible for an OrMatchExpression to have no children, resulting in the serialized // expression {$or: []}, which is not a valid query object. An empty $or is logically // equivalent to {$alwaysFalse: 1}. out->append(AlwaysFalseMatchExpression::kName, 1); return; } BSONArrayBuilder arrBob(out->subarrayStart("$or")); _listToBSON(&arrBob); }
void InMatchExpression::serialize(BSONObjBuilder* out) const { BSONObjBuilder inBob(out->subobjStart(path())); BSONArrayBuilder arrBob(inBob.subarrayStart("$in")); for (auto&& _equality : _equalitySet) { arrBob.append(_equality); } for (auto&& _regex : _regexes) { BSONObjBuilder regexBob; _regex->serializeToBSONTypeRegex(®exBob); arrBob.append(regexBob.obj().firstElement()); } arrBob.doneFast(); inBob.doneFast(); }
void NorMatchExpression::serialize(BSONObjBuilder* out) const { BSONArrayBuilder arrBob(out->subarrayStart("$nor")); _listToBSON(&arrBob); }
void InMatchExpression::toBSON(BSONObjBuilder* out) const { BSONObjBuilder inBob(out->subobjStart(path())); BSONArrayBuilder arrBob(inBob.subarrayStart("$in")); _arrayEntries.toBSON(&arrBob); inBob.doneFast(); }
void OrMatchExpression::toBSON(BSONObjBuilder* out) const { BSONArrayBuilder arrBob(out->subarrayStart("$or")); _listToBSON(&arrBob); }