Closed azhang closed 8 years ago
You can always just wrap the query in an object, like return { q: query }
What was the reasoning for putting .exec() thenable functionality into the Query itself? It seems redundant and confusing to make Query a thenable and have .exec(), when both behave the same when used with promises.
The reason was so you could do yield MyModel.findOne()
when using co, without needing the extra .exec()
, because that's a much more common use case than returning a query from a promise AFAIK.
Also, they don't behave exactly the same. You can't .catch()
on a query, for instance.
I'd like to return a query object from a promise (so I can reuse it with different chained methods), but since the query object is a thenable, it'll always resolve before I get there. Any way to work around this?