【发布时间】:2018-03-07 05:47:50
【问题描述】:
我刚刚安装了 Robo3T(以前称为 robomongo),它有一个用于 mongo db 的 GUI。 我想添加一个自定义函数来帮助我按正常顺序获取最后N个文档,查询语句是这样的:
db.getCollection('i1801').find().skip(db.getCollection('i1801').count() - 1200)
我从stackoverflow(mongodb: how to get the last N records?)中发现,这可以写成这样的函数:
function last(N) {
return db.collection.find().skip(db.collection.count() - N);
}
然后我回到我的 Robo3T,尝试添加自定义函数 last(),但没有成功,函数选项卡下没有任何显示。
我附上了一些说明这个问题的屏幕截图:
点击保存按钮后,什么也没发生,功能选项卡下仍然没有功能。并且日志显示函数last 创建,并且函数选项卡正在刷新。
那么,如何在此处添加last 函数?
【问题讨论】:
标签: javascript mongodb robo3t