コード例 #1
0
stdx::optional<result::delete_result> collection::delete_one(
    bsoncxx::document::view filter, const options::delete_options& options) {
    class bulk_write bulk_op(false);
    model::delete_one delete_op(filter);
    bulk_op.append(delete_op);

    if (options.write_concern()) bulk_op.write_concern(*options.write_concern());

    auto result = bulk_write(bulk_op);
    if (!result) {
        return stdx::optional<result::delete_result>();
    }
    return stdx::optional<result::delete_result>(result::delete_result(std::move(result.value())));
}
コード例 #2
0
stdx::optional<result::delete_result> collection::delete_one(
    view_or_value filter, const options::delete_options& options) {
    options::bulk_write bulk_opts;
    bulk_opts.ordered(false);

    if (options.write_concern()) bulk_opts.write_concern(*options.write_concern());

    class bulk_write bulk_op(bulk_opts);

    model::delete_one delete_op(filter);
    bulk_op.append(delete_op);

    auto result = bulk_write(bulk_op);
    if (!result) {
        return stdx::optional<result::delete_result>();
    }
    return stdx::optional<result::delete_result>(result::delete_result(std::move(result.value())));
}
コード例 #3
0
stdx::optional<result::delete_result> collection::delete_many(
    view_or_value filter, const options::delete_options& options) {
    options::bulk_write bulk_opts;
    bulk_opts.ordered(false);

    if (options.write_concern()) {
        bulk_opts.write_concern(*options.write_concern());
    }

    auto bulk_op = create_bulk_write(bulk_opts);

    model::delete_many delete_op(filter);
    if (options.collation()) {
        delete_op.collation(*options.collation());
    }
    bulk_op.append(delete_op);

    auto result = bulk_write(bulk_op);
    if (!result) {
        return stdx::nullopt;
    }

    return stdx::optional<result::delete_result>(result::delete_result(std::move(result.value())));
}