Beispiel #1
0
bsoncxx::document::value database::modify_collection(stdx::string_view name,
                                                     const options::modify_collection& options) {
    auto doc = make_document(kvp("collMod", name), concatenate(options.to_document()));

    return run_command(doc.view());
}
Beispiel #2
0
bsoncxx::document::value database::modify_collection(stdx::string_view name,
                                                     const options::modify_collection& options) {
    auto doc = document{} << "collMod" << name << concatenate(options.to_document()) << finalize;

    return run_command(doc.view());
}
#include <bsoncxx/types.hpp>
#include <bsoncxx/types/value.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/options/modify_collection.hpp>

using namespace bsoncxx;
using namespace mongocxx;

using builder::stream::close_document;
using builder::stream::finalize;
using builder::stream::open_document;

TEST_CASE("modify_collection", "[modify_collection]") {
    instance::current();

    options::modify_collection cm;

    SECTION("Can be exported to a document") {
        auto rule = builder::stream::document{} << "brain" << open_document << "$exists" << true
                                                << close_document << finalize;

        validation_criteria validation;
        validation.rule(rule.view());
        validation.level(validation_criteria::validation_level::k_strict);

        auto index = builder::stream::document{} << "a" << 1 << finalize;

        cm.index(index.view(), std::chrono::seconds(10));
        cm.validation_criteria(validation);
        cm.no_padding(false);