📜  获取 mongodb 中的最后 N 条记录 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:58.586000             🧑  作者: Mango

代码示例2
In order to get last N records you can execute below query:

db.yourcollectionname.find({$query: {}, $orderby: {$natural : -1}}).limit(yournumber)
if you want only one last record:

db.yourcollectionname.findOne({$query: {}, $orderby: {$natural : -1}})