本文整理汇总了C++中bsoncxx::string::view_or_value类的典型用法代码示例。如果您正苦于以下问题:C++ view_or_value类的具体用法?C++ view_or_value怎么用?C++ view_or_value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了view_or_value类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_view
class collection database::create_view(bsoncxx::string::view_or_value name,
bsoncxx::string::view_or_value view_on,
const options::create_view& options) {
bsoncxx::builder::basic::document options_builder;
options_builder.append(kvp("viewOn", view_on));
if (options.collation()) {
options_builder.append(kvp("collation", *options.collation()));
}
if (options.pipeline()) {
options_builder.append(kvp("pipeline", options.pipeline()->view_array()));
}
if (options.write_concern()) {
options_builder.append(kvp("writeConcern", options.write_concern()->to_document()));
}
libbson::scoped_bson_t opts_bson{options_builder.view()};
bson_error_t error;
auto result = libmongoc::database_create_collection(
_get_impl().database_t, name.terminated().data(), opts_bson.bson(), &error);
if (!result) {
throw_exception<operation_exception>(error);
}
return mongocxx::collection(*this, result);
}
开发者ID:bsamek,项目名称:mongo-cxx-driver,代码行数:28,代码来源:database.cpp
示例2: has_collection
bool database::has_collection(bsoncxx::string::view_or_value name) const {
bson_error_t error;
auto result = libmongoc::database_has_collection(_get_impl().database_t,
name.terminated().data(), &error);
if (error.domain != 0) {
throw_exception<operation_exception>(error);
}
return result;
}
开发者ID:ilri,项目名称:odktools,代码行数:10,代码来源:database.cpp
示例3: rename
void collection::rename(bsoncxx::string::view_or_value new_name, bool drop_target_before_rename) {
bson_error_t error;
auto result = libmongoc::collection_rename(
_get_impl().collection_t, _get_impl().database_name.c_str(), new_name.terminated().data(),
drop_target_before_rename, &error);
if (!result) {
throw_exception<operation_exception>(error);
}
}
开发者ID:adamchel,项目名称:mongo-cxx-driver,代码行数:11,代码来源:collection.cpp
示例4: create_collection
class collection database::create_collection(bsoncxx::string::view_or_value name,
const options::create_collection& options) {
bson_error_t error;
libbson::scoped_bson_t opts_bson{options.to_document()};
auto result = libmongoc::database_create_collection(
_get_impl().database_t, name.terminated().data(), opts_bson.bson(), &error);
if (!result) {
throw_exception<operation_exception>(error);
}
return mongocxx::collection(*this, static_cast<void*>(result));
}
开发者ID:jbreams,项目名称:mongo-cxx-driver,代码行数:14,代码来源:database.cpp
示例5: distinct
cursor collection::distinct(bsoncxx::string::view_or_value field_name, view_or_value query,
const options::distinct& options) {
bsoncxx::builder::stream::document command_builder{};
command_builder << "distinct" << name() << "key" << field_name.view() << "query"
<< bsoncxx::types::b_document{query};
if (options.max_time()) {
command_builder << "maxTimeMS" << options.max_time()->count();
}
scoped_bson_t command_bson{command_builder.extract()};
auto database = libmongoc::client_get_database(_get_impl().client_impl->client_t,
_get_impl().database_name.c_str());
auto result = libmongoc::database_command(database, MONGOC_QUERY_NONE, 0, 0, 0,
command_bson.bson(), NULL, NULL);
return cursor(result);
}
开发者ID:gsanish,项目名称:mongo-cxx-driver,代码行数:20,代码来源:collection.cpp
示例6: rename
void collection::rename(bsoncxx::string::view_or_value new_name,
bool drop_target_before_rename,
const bsoncxx::stdx::optional<mongocxx::write_concern>& wc) {
bson_error_t error;
bsoncxx::builder::basic::document opts_doc;
if (wc) {
opts_doc.append(kvp("writeConcern", wc->to_document()));
}
scoped_bson_t opts_bson{opts_doc.view()};
bool result = libmongoc::collection_rename_with_opts(_get_impl().collection_t,
_get_impl().database_name.c_str(),
new_name.terminated().data(),
drop_target_before_rename,
opts_bson.bson(),
&error);
if (!result) {
throw_exception<operation_exception>(error);
}
}
开发者ID:bsamek,项目名称:mongo-cxx-driver,代码行数:23,代码来源:collection.cpp
示例7: create_view
class collection database::create_view(bsoncxx::string::view_or_value name,
bsoncxx::string::view_or_value view_on,
const options::create_view& options) {
document options_builder{};
options_builder << "viewOn" << view_on;
if (options.collation()) {
options_builder << "collation" << *options.collation();
}
if (options.pipeline()) {
options_builder << "pipeline" << options.pipeline()->view_array();
}
libbson::scoped_bson_t opts_bson{options_builder.view()};
bson_error_t error;
auto result = libmongoc::database_create_collection(
_get_impl().database_t, name.terminated().data(), opts_bson.bson(), &error);
if (!result) {
throw_exception<operation_exception>(error);
}
return mongocxx::collection(*this, result);
}
开发者ID:ilri,项目名称:odktools,代码行数:24,代码来源:database.cpp
示例8: distinct
cursor collection::distinct(bsoncxx::string::view_or_value field_name,
view_or_value query,
const options::distinct& options) {
//
// Construct the distinct command and options.
//
bsoncxx::builder::basic::document command_builder;
command_builder.append(kvp("distinct", name()),
kvp("key", field_name.view()),
kvp("query", bsoncxx::types::b_document{query}));
if (options.max_time()) {
command_builder.append(
kvp("maxTimeMS", bsoncxx::types::b_int64{options.max_time()->count()}));
}
bsoncxx::builder::basic::document opts_builder{};
if (options.collation()) {
opts_builder.append(kvp("collation", *options.collation()));
}
const mongoc_read_prefs_t* rp_ptr = NULL;
if (options.read_preference()) {
rp_ptr = options.read_preference()->_impl->read_preference_t;
}
//
// Send the command and validate the reply.
//
scoped_bson_t reply;
reply.flag_init();
bson_error_t error;
scoped_bson_t command_bson{command_builder.extract()};
scoped_bson_t opts_bson{opts_builder.extract()};
auto result = libmongoc::collection_read_command_with_opts(_get_impl().collection_t,
command_bson.bson(),
rp_ptr,
opts_bson.bson(),
reply.bson(),
&error);
if (!result) {
throw_exception<operation_exception>(error);
}
//
// Fake a cursor with the reply document as a single result.
//
auto fake_db_reply = make_document(
kvp("ok", 1), kvp("cursor", [&reply](sub_document sub_doc) {
sub_doc.append(
kvp("ns", ""), kvp("id", 0), kvp("firstBatch", [&reply](sub_array sub_arr) {
sub_arr.append(reply.view());
}));
}));
bson_t* reply_bson =
bson_new_from_data(fake_db_reply.view().data(), fake_db_reply.view().length());
if (!reply_bson) {
throw bsoncxx::exception{bsoncxx::error_code::k_internal_error};
}
cursor fake_cursor{
libmongoc::cursor_new_from_command_reply(_get_impl().client_impl->client_t, reply_bson, 0)};
if (libmongoc::cursor_error(fake_cursor._impl->cursor_t, &error)) {
throw_exception<operation_exception>(error);
}
return fake_cursor;
}
开发者ID:xdg,项目名称:mongo-cxx-driver,代码行数:71,代码来源:collection.cpp
示例9:
collection::collection(const database& database, bsoncxx::string::view_or_value collection_name)
: _impl(stdx::make_unique<impl>(
libmongoc::database_get_collection(database._get_impl().database_t,
collection_name.terminated().data()),
database.name(),
database._get_impl().client_impl)) {}
开发者ID:xdg,项目名称:mongo-cxx-driver,代码行数:6,代码来源:collection.cpp
示例10: create_collection
class collection database::create_collection(bsoncxx::string::view_or_value name,
const options::create_collection& options) {
document options_builder{};
if (options.auto_index_id()) {
options_builder << "autoIndexId" << *options.auto_index_id();
}
if (options.capped()) {
options_builder << "capped" << *options.capped();
}
if (options.collation()) {
options_builder << "collation" << *options.collation();
}
if (options.max()) {
options_builder << "max" << *options.max();
}
if (options.no_padding()) {
options_builder << "flags" << (*options.no_padding() ? 0x10 : 0x00);
}
if (options.size()) {
options_builder << "size" << *options.size();
}
if (options.storage_engine()) {
options_builder << "storageEngine" << *options.storage_engine();
}
if (options.validation_criteria()) {
auto validation_level_to_string = [](validation_criteria::validation_level level) {
switch (level) {
case validation_criteria::validation_level::k_off:
return "off";
case validation_criteria::validation_level::k_moderate:
return "moderate";
case validation_criteria::validation_level::k_strict:
return "strict";
}
MONGOCXX_UNREACHABLE;
};
auto validation_action_to_string = [](validation_criteria::validation_action action) {
switch (action) {
case validation_criteria::validation_action::k_warn:
return "warn";
case validation_criteria::validation_action::k_error:
return "error";
}
MONGOCXX_UNREACHABLE;
};
auto validation_criteria = *options.validation_criteria();
if (validation_criteria.rule()) {
options_builder << "validator" << *validation_criteria.rule();
}
if (validation_criteria.level()) {
options_builder << "validationLevel"
<< validation_level_to_string(*validation_criteria.level());
}
if (validation_criteria.action()) {
options_builder << "validationAction"
<< validation_action_to_string(*validation_criteria.action());
}
}
bson_error_t error;
libbson::scoped_bson_t opts_bson{options_builder.view()};
auto result = libmongoc::database_create_collection(
_get_impl().database_t, name.terminated().data(), opts_bson.bson(), &error);
if (!result) {
throw_exception<operation_exception>(error);
}
return mongocxx::collection(*this, result);
}
开发者ID:ilri,项目名称:odktools,代码行数:82,代码来源:database.cpp
示例11: create_collection
class collection database::create_collection(
bsoncxx::string::view_or_value name,
const options::create_collection& collection_options,
const stdx::optional<class write_concern>& write_concern) {
bsoncxx::builder::basic::document options_builder;
if (write_concern) {
options_builder.append(kvp("writeConcern", write_concern->to_document()));
}
if (collection_options.auto_index_id()) {
options_builder.append(kvp("autoIndexId", *collection_options.auto_index_id()));
}
if (collection_options.capped()) {
options_builder.append(kvp("capped", *collection_options.capped()));
}
if (collection_options.collation()) {
options_builder.append(kvp("collation", *collection_options.collation()));
}
if (collection_options.max()) {
options_builder.append(kvp("max", *collection_options.max()));
}
if (collection_options.no_padding()) {
options_builder.append(kvp("flags", (*collection_options.no_padding() ? 0x10 : 0x00)));
}
if (collection_options.size()) {
options_builder.append(kvp("size", *collection_options.size()));
}
if (collection_options.storage_engine()) {
options_builder.append(kvp("storageEngine", *collection_options.storage_engine()));
}
if (collection_options.validation_criteria()) {
auto validation_level_to_string = [](validation_criteria::validation_level level) {
switch (level) {
case validation_criteria::validation_level::k_off:
return "off";
case validation_criteria::validation_level::k_moderate:
return "moderate";
case validation_criteria::validation_level::k_strict:
return "strict";
}
MONGOCXX_UNREACHABLE;
};
auto validation_action_to_string = [](validation_criteria::validation_action action) {
switch (action) {
case validation_criteria::validation_action::k_warn:
return "warn";
case validation_criteria::validation_action::k_error:
return "error";
}
MONGOCXX_UNREACHABLE;
};
auto validation_criteria = *collection_options.validation_criteria();
if (validation_criteria.rule()) {
options_builder.append(kvp("validator", *validation_criteria.rule()));
}
if (validation_criteria.level()) {
options_builder.append(
kvp("validationLevel", validation_level_to_string(*validation_criteria.level())));
}
if (validation_criteria.action()) {
options_builder.append(kvp("validationAction",
validation_action_to_string(*validation_criteria.action())));
}
}
bson_error_t error;
libbson::scoped_bson_t opts_bson{options_builder.view()};
auto result = libmongoc::database_create_collection(
_get_impl().database_t, name.terminated().data(), opts_bson.bson(), &error);
if (!result) {
throw_exception<operation_exception>(error);
}
return mongocxx::collection(*this, result);
}
开发者ID:bsamek,项目名称:mongo-cxx-driver,代码行数:88,代码来源:database.cpp
示例12: has_collection
bool database::has_collection(bsoncxx::string::view_or_value name) const {
bson_error_t error;
return libmongoc::database_has_collection(_get_impl().database_t, name.terminated().data(),
&error);
}
开发者ID:jbreams,项目名称:mongo-cxx-driver,代码行数:5,代码来源:database.cpp
示例13:
uri::uri(bsoncxx::string::view_or_value uri_string)
: _impl(stdx::make_unique<impl>(libmongoc::uri_new(uri_string.terminated().data()))) {
}
开发者ID:Machyne,项目名称:mongo-cxx-driver,代码行数:3,代码来源:uri.cpp
注:本文中的bsoncxx::string::view_or_value类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论