Skip to content

Commit c5b2355

Browse files
authored
docs(promises): add note about queries being thenable
Fix #8110
1 parent da77b8d commit c5b2355

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/docs/promises.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ describe('promises docs', function () {
8484
});
8585
});
8686

87+
/**
88+
* Although queries are not promises, queries are [thenables](https://promisesaplus.com/#terminology).
89+
* That means they have a `.then()` function, so you can use queries as promises with either
90+
* promise chaining or [async await](https://asyncawait.net)
91+
*/
92+
it('Queries are thenable', function (done) {
93+
Band.findOne({name: "Guns N' Roses"}).then(function(doc) {
94+
// use doc
95+
// acquit:ignore:start
96+
assert.ok(!doc);
97+
done();
98+
// acquit:ignore:end
99+
});
100+
});
101+
87102
/**
88103
* If you're an advanced user, you may want to plug in your own promise
89104
* library like [bluebird](https://www.npmjs.com/package/bluebird). Just set

0 commit comments

Comments
 (0)