Skip to content

Commit

Permalink
docs(promises): add note about queries being thenable
Browse files Browse the repository at this point in the history
Fix #8110
  • Loading branch information
vkarpov15 committed Sep 27, 2019
1 parent da77b8d commit c5b2355
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/docs/promises.test.js
Expand Up @@ -84,6 +84,21 @@ describe('promises docs', function () {
});
});

/**
* Although queries are not promises, queries are [thenables](https://promisesaplus.com/#terminology).
* That means they have a `.then()` function, so you can use queries as promises with either
* promise chaining or [async await](https://asyncawait.net)
*/
it('Queries are thenable', function (done) {
Band.findOne({name: "Guns N' Roses"}).then(function(doc) {
// use doc
// acquit:ignore:start
assert.ok(!doc);
done();
// acquit:ignore:end
});
});

/**
* If you're an advanced user, you may want to plug in your own promise
* library like [bluebird](https://www.npmjs.com/package/bluebird). Just set
Expand Down

0 comments on commit c5b2355

Please sign in to comment.