私はCプログラムを初めて使用し、現在Mongodbからデータを取得し、このデータをあるコレクションから別のコレクションに移動するCプログラムを作成しています。
データを取得するための私のコードは次のとおりです。
bson query[1];
bson_init(query);
bson_append_start_object(query,"time");
bson_append_string(query, "$gt", starttime);
bson_append_string(query, "$lte", endtime);
bson_append_finish_object(query);
bson_finish(query);
mongo_cursor cursor[1];
mongo_cursor_init( cursor, conn, "dbA.collectionA");
mongo_cursor_set_query( cursor, query);
while( mongo_cursor_next(cursor) == MONGO_OK){
//read the data and display it
...
//here I want to move the documents from collectionA to collectionB
}
データを正常に表示できましたが、このデータを表示した後に別のコレクションに移動する方法がわかりません。
ありがとうございます !!