inside my frontend and after authenticating a user, I have the following code that works: ..
...
.then(authedUser =>
db
.collection('comments')
.find({}, { limit: 1 })
.asArray()
)
.then(doc => console.log('doc:', doc)); // 1 doc returned as array, yes!
However, the following code doesn't work: .
...
.then(authedUser =>
db
.collection('comments')
.find({})
.limit(1)
.asArray()
)
.then(doc => console.log('doc:', doc)); // error inside Promise, limit is not a function...
May I know why? I know that limit() is a cursor method and $limit is an aggregate stage, so now I am a bit confused.