【发布时间】:2018-11-30 00:27:30
【问题描述】:
在我的前端和验证用户后,我有以下代码可以工作: ..
...
.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 是一个聚合阶段,所以现在我有点困惑。
【问题讨论】:
-
asArray()对于 SDK 是正确的。这是使用缝合,所以它与驱动程序不同。 -
是的,我正在使用并参考 Stitch SDK。