Beispiel #1
0
// static
void ProjectionStage::transformSimpleInclusion(const BSONObj& in,
                                               const FieldSet& includedFields,
                                               BSONObjBuilder& bob) {
    // Look at every field in the source document and see if we're including it.
    BSONObjIterator inputIt(in);
    while (inputIt.more()) {
        BSONElement elt = inputIt.next();
        auto fieldIt = includedFields.find(elt.fieldNameStringData());
        if (includedFields.end() != fieldIt) {
            // If so, add it to the builder.
            bob.append(elt);
        }
    }
}
Beispiel #2
0
bool DBOperation::verify_fields(const dclass::Class *dclass, const FieldSet& fields)
{
    bool valid = true;
    for(auto it = fields.begin(); it != fields.end(); ++it) {
        const dclass::Field *field = *it;
        if(!dclass->get_field_by_id(field->get_id())) {
            m_dbserver->m_log->warning() << "Field " << field->get_name()
                                         << " does not belong to object " << m_doid
                                         << "(" << dclass->get_name() << ")\n";
            valid = false;
        }
    }
    return valid;
}