bool match(const mutablebson::ConstElement& element) final {
     if (element.getType() == mongo::Object) {
         return _matchExpr->matchesBSON(element.getValueObject());
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
bool ModifierPull::isMatch(mutablebson::ConstElement element) {
    // TODO: We are assuming that 'element' hasValue is true. That might be OK if the
    // conflict detection logic will prevent us from ever seeing a deserialized element,
    // but are we sure about that?

    dassert(element.hasValue());

    if (!_matchExpr)
        return (element.compareWithBSONElement(_exprElt, _collator, false) == 0);

    if (_matcherOnPrimitive) {
        // TODO: This is kinda slow.
        BSONObj candidate = element.getValue().wrap("");
        return _matchExpr->matchesBSON(candidate);
    }

    if (element.getType() != Object)
        return false;

    return _matchExpr->matchesBSON(element.getValueObject());
}