在我的前端和认证用户后,我有以下代码可以工作:
…
...
.then(authedUser =>
db
.collection('comments')
.find({}, { limit: 1 })
.asArray()
)
.then(doc => console.log('doc:', doc)); // 1 doc returned as array, yes!
但是,以下代码不起作用:
.
...
.then(authedUser =>
db
.collection('comments')
.find({})
.limit(1)
.asArray()
)
.then(doc => console.log('doc:', doc)); // error inside Promise, limit is not a function...
我能知道为什么吗?我知道limit()是一个游标方法,$limit是一个聚合阶段,所以现在我有点困惑了。