我正在尝试反向显示集合的文档。在 shell 中,这可以通过使用以下命令来完成:
db.testcollection.find().sort({$natural:-1})
在文档中我发现了这个功能:
void sort(bsoncxx::document::view_or_value ordering);
/// The order in which to return matching documents. If $orderby also exists in the modifiers
/// document, the sort field takes precedence over $orderby.
///
/// @param ordering
/// Document describing the order of the documents to be returned.
///
/// @see http://docs.mongodb.org/manual/reference/method/cursor.sort/
如何像 shell 示例中那样将 natural 设置为 -1?谢谢!