6 #include <knowrob/storage/mongo/Database.h>
7 #include <knowrob/storage/mongo/MongoException.h>
13 client_ = mongoc_client_pool_pop(pool_);
14 db_ = mongoc_client_get_database(client_, db_name.data());
18 mongoc_database_destroy(db_);
19 mongoc_client_pool_push(pool_, client_);
28 for (
auto &is : indexes) {
29 BSON_APPEND_INT32(&keys, is.value.c_str(), (
int)is.type);
31 char *index_name = mongoc_collection_keys_to_index_string(&keys);
33 bson_t *cmd = BCON_NEW (
"createIndexes", BCON_UTF8(coll_name),
35 "key", BCON_DOCUMENT(&keys),
36 "name", BCON_UTF8(index_name),
39 bool success = mongoc_database_write_command_with_opts(
40 db_, cmd,
nullptr , &reply, &err);
41 bson_free(index_name);
Database(mongoc_client_pool_t *pool, std::string_view db_name)
bool create_index(const char *coll_name, const std::vector< IndexKey > &indexes)