Skip to content

Commit ef1b15e

Browse files
authored
Update README.md
Add note on "bring your own promise"
1 parent 22a76dd commit ef1b15e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,27 @@ PGSSLMODE=require
275275

276276
Usually I will export these into my local environment via a `.env` file with environment settings or export them in `~/.bash_profile` or something similar. This way I get configurability which works with both the postgres suite of tools (`psql`, `pg_dump`, `pg_restore`) and node, I can vary the environment variables locally and in production, and it supports the concept of a [12-factor app](http://12factor.net/) out of the box.
277277

278+
## bring your own promise
279+
280+
In versions of node `<=0.12.x` there is no native promise implementation available globally. You can polyfill the promise globally like this:
281+
282+
```js
283+
// first run `npm install promise-polyfill --save
284+
if (typeof Promise == 'undefined') {
285+
global.Promise = require('promise-polyfill')
286+
}
287+
```
288+
289+
You can use any other promise implementation you'd like. The pool also allows you to configure the promise implementation on a per-pool level:
290+
291+
```js
292+
var bluebirdPool = new Pool({
293+
Promise: require('bluebird')
294+
})
295+
```
296+
297+
__please note:__ in node `<=0.12.x` the pool will throw if you do not provide a promise constructor in one of the two ways mentioned above. In node `>=4.0.0` the pool will use the native promise implementation by default; however, the two methods above still allow you to "bring your own."
298+
278299
## tests
279300

280301
To run tests clone the repo, `npm i` in the working dir, and then run `npm test`

0 commit comments

Comments
 (0)