1

我正在尝试重命名 C 程序中的集合,但这不起作用:

commandData = (bson *) malloc(sizeof(bson));
commandOut = (bson *) malloc(sizeof(bson));

int result;

bson_init(commandData);
bson_init(commandOut);
bson_append_string(commandData, "renameCollection", "pru.collecPRU");
bson_append_string(commandData, "to", "pru.collecOK");
bson_append_bool(commandData, "dropTarget", 1);

result = mongo_run_command(conn, "admin", commandData, commandOut);

if(result != MONGO_OK) {
  fprintf(stderr, "%s Rename ERROR\n", dateTime);
  bson_destroy(commandOut);
  free(commandOut);
}

bson_destroy(commandData);
free(commandData);

有人可以帮帮我吗?

4

0 回答 0