0
这里复杂的查询是我收集的结构部分:
...
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);
}
...
}
...
但是:
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恢复我的数据现在我想按时间顺序(或不是)检索数组“邮件”中的所有值...您是否了解该过程?
顺便说一句,看起来你正在通过'filename'键在你的代码中进行排序。你在示例文档中没有这个键。 – vbo
对不起,我的错。这是时间戳记密钥,不是文件名 –
没关系。顺便说一句,检查我的答案,也许它会帮助你。 – vbo