Skip to content

Commit 2682ea1

Browse files
authored
Merge pull request #31 from temsa/patch-1
Update README.md to explain how to run the tests
2 parents d272216 + 1259bd0 commit 2682ea1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/fastify/fastify-postgres.svg?branch=master)](https://travis-ci.org/fastify/fastify-postgres)
66

7-
Fastify PostgreSQL connection plugin, with this you can share the same PostgreSQL connection pool in every part of your server.
7+
Fastify PostgreSQL connection plugin, with this you can share the same PostgreSQL connection pool in every part of your server.
88
Under the hood the [node-postgres](https://github.com/brianc/node-postgres) is used, the options that you pass to `register` will be passed to the PostgreSQL pool builder.
99

1010
## Install
1111
```
1212
npm i fastify-postgres --save
1313
```
1414
## Usage
15-
Add it to you project with `register` and you are done!
15+
Add it to you project with `register` and you are done!
1616
This plugin will add the `pg` namespace in your Fastify instance, with the following properties:
1717
```
1818
connect: the function to get a connection from the pool
@@ -131,7 +131,7 @@ fastify.pg.transact(client => {
131131

132132
/* or with a commit callback
133133
134-
fastify.pg.transact((client, commit) => {
134+
fastify.pg.transact((client, commit) => {
135135
client.query('INSERT INTO users(username) VALUES($1) RETURNING id', [req.params.username], (err, id) => {
136136
commit(err, id)
137137
});
@@ -211,9 +211,16 @@ First, start postgres with:
211211
$ npm run postgres
212212
```
213213

214-
Then in another terminal:
214+
Then you can, in another terminal, find the running docker, init the DB, then run the tests:
215215

216216
```
217+
$ docker ps
218+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
219+
28341f85c4cd postgres:9.6-alpine "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:5432->5432/tcp jovial_shockley
220+
221+
$ docker exec -ti jovial_shockley /usr/local/bin/psql -d postgres -U postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);'
222+
CREATE TABLE
223+
217224
$ npm test
218225
```
219226

0 commit comments

Comments
 (0)