これが私のコレクションの構造部分です:
by: [
{
id: ObjectId("XX"),
type: NumberInt(1)
}
],
timestamp: NumberInt(), // is timestamp 1
status: NumberInt(0),
mails: [
{
id: ObjectId("YY"),
text: "",
timestamp: NumberInt(), // is timestamp 2
}
]
次の行を使用して、タイムスタンプ 1 に従って時系列順にデータを復元できます。
...
bson_init(&query);
bson_append_document_begin(&query, "$orderby", -1, &child);
bson_append_int32(&child, "timestamp", -1, 1);
bson_append_document_end(&query, &child);
bson_append_document_begin(&query, "$query", -1, &child);
bson_append_document_end(&query, &child);
collection = mongoc_client_get_collection(client, "db", "prefix");
cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 0, 0, &query, NULL, NULL);
while(mongoc_cursor_next(cursor, &doc)){
bson_iter_t iter;
if(bson_iter_init_find(&iter, doc, "status")){
status = bson_iter_int32(&iter);
}
...
}
...
しかし今、配列「メール」のすべての値を時系列で (またはそうではなく) 取得したいと思います...手順についてのアイデアはありますか?