Status removeAuthzDocuments(OperationContext* txn,
                            const NamespaceString& collectionName,
                            const BSONObj& query,
                            long long* numRemoved) {
    try {
        DBDirectClient client(txn);

        auto doc = stdx::make_unique<BatchedDeleteDocument>();
        doc->setQuery(query);
        doc->setLimit(0);

        BatchedDeleteRequest req;
        req.setNS(collectionName);
        req.addToDeletes(doc.release());

        BSONObj res;
        client.runCommand(collectionName.db().toString(), req.toBSON(), res);

        BatchedCommandResponse response;
        std::string errmsg;
        if (!response.parseBSON(res, &errmsg)) {
            return Status(ErrorCodes::FailedToParse, errmsg);
        }
        if (response.getOk()) {
            *numRemoved = response.getN();
        }
        return response.toStatus();
    } catch (const DBException& e) {
        return e.toStatus();
    }
}
Status removeAuthzDocuments(OperationContext* txn,
                            const NamespaceString& collectionName,
                            const BSONObj& query,
                            long long* numRemoved) {
    try {
        DBDirectClient client(txn);

        auto doc = stdx::make_unique<BatchedDeleteDocument>();
        doc->setQuery(query);
        doc->setLimit(0);

        BatchedDeleteRequest req;
        req.setNS(collectionName);
        req.addToDeletes(doc.release());

        BSONObj res;
        client.runCommand(collectionName.db().toString(), req.toBSON(), res);

        BatchedCommandResponse response;
        std::string errmsg;
        if (!response.parseBSON(res, &errmsg)) {
            return Status(ErrorCodes::FailedToParse, errmsg);
        }
        if (response.getOk()) {
            *numRemoved = response.getN();
        }
        return response.toStatus();
    } catch (const DBException& e) {
        return e.toStatus();
    }
}