Closed EduardoRFS closed 7 years ago
Good suggestion, but to make .catch()
work, I'd implement that like:
then() {
return new Promise((resolve, reject) => {
return new this.model.dbCollection()
.then(collection => this.mquery.collection(collection))
.then(resolve, reject);
});
}
Also, do you mind adding a test to confirm it's working?
@vdemedes refactored Query, removed unnecessary code and allowed syntax like .findOne().where(...)
, .catch
is after .then
ex: .findOne().then(...).catch(...)
. Basically with this PR Query is a instanceof
mquery, with custom .then
all tests use .then
Could you revert this PR back to its original point, without making Query
extend mquery
?
In future, please consider opening an issue or discussing in the PR first, before making major changes. That way, you avoid extra work that might be rejected and you don't waste your precious time ;)
Reverted, i make that to use in a project. Is only a suggestion
Recently I hit this issue too, at first I expose mquery instance and implement then method to using findOneAndUpdate, then I realize the return is just like the native driver, to using like mongorito still need write hooks and wrap, like an wrap method of query, other hand the dbCollection is enough.
Closing, turns out this is a bad practice, see https://github.com/vadimdemedes/mongorito/issues/176.
When execute mquery methods on Query class, not have .then method
before:
after: