Would this be valid?

        insertedDoc = BSON("_id" << BSON(ENT_ENTITY_ID << e.id) <<
           ENT_ATTRS << attrsToAdd.arr() <<
           ENT_CREATION_DATE << now <<
           ENT_MODIFICATION_DATE << now;

        if (e.type != "")
            insertedDoc << ENT_ATTRS << attrsToAdd.arr();