static void
test_index (void)
{
   mongoc_collection_t *collection;
   mongoc_client_t *client;
   mongoc_index_opt_t opt;
   bson_error_t error;
   bool r;
   bson_t keys;

   mongoc_index_opt_init(&opt);

   client = mongoc_client_new(gTestUri);
   ASSERT (client);

   collection = mongoc_client_get_collection(client, "test", "test");
   ASSERT (collection);

   bson_init(&keys);
   bson_append_int32(&keys, "hello", -1, 1);
   r = mongoc_collection_ensure_index(collection, &keys, &opt, &error);
   ASSERT (r);

   r = mongoc_collection_ensure_index(collection, &keys, &opt, &error);
   ASSERT (r);

   r = mongoc_collection_drop_index(collection, "hello_1", &error);
   ASSERT (r);

   bson_destroy(&keys);

   mongoc_collection_destroy(collection);
   mongoc_client_destroy(client);
}
示例#2
0
SEXP R_mongo_collection_drop_index(SEXP ptr_col, SEXP name) {
  mongoc_collection_t *col = r2col(ptr_col);
  const char *str =  Rf_translateCharUTF8(Rf_asChar(name));
  bson_error_t err;

  if(!mongoc_collection_drop_index(col, str, &err))
    stop(err.message);

  return Rf_ScalarLogical(1);
}
示例#3
0
bool dbproxy::drop_index (std::string collection, const std::string index_name, bson_error_t * error) {
    mongoc_collection_t * _c = get_collection(collection);
    return mongoc_collection_drop_index(_c, index_name.c_str(), error);
}