# fastify-postgresjs

> Fastify postgres.js plugin

Latest version **1.0.0** (published 2020-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install fastify-postgresjs
pnpm add fastify-postgresjs
yarn add fastify-postgresjs
bun add fastify-postgresjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-02-02 |
| First published | 2020-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | René Herrmann |
| Maintainers | herrmannplatz |
| Keywords | postgres, postgresql, sql, postgres.js, connection, database, fastify, fastify-plugin |

## Links

- npm: https://www.npmjs.com/package/fastify-postgresjs
- Repository: https://github.com/herrmannplatz/fastify-postgresjs
- Homepage: https://github.com/herrmannplatz/fastify-postgresjs#readme
- Issues: https://github.com/herrmannplatz/fastify-postgresjs/issues
- npm.io page: https://npm.io/package/fastify-postgresjs

## Dependencies (1)

- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^1.6.0

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-02-02
- 1.1.0 (next) — 2020-02-02

## README

# fastify-postgresjs

[![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/herrmannplatz/fastify-postgresjs)

Fastify PostgreSQL connection plugin, based on [postgres](https://github.com/porsager/postgres).

## Install

```
npm i postgres fastify-postgresjs --save
```

## Usage

Add it to you project with `register` and you are done!
This plugin will add the `sql` namespace in your Fastify instance.

Example:

```js
const fastify = require("fastify")();

fastify.register(require("fastify-postgresjs"), {
  url: "postgres://postgres@localhost/postgres"
});

fastify.get("/users/:id", async (req, reply) => {
  const users = await fastify.sql`
    select * from users
    where id = ${req.params.id}
  `;
  return users;
});

fastify.listen(3000, err => {
  if (err) throw err;
  console.log(`server listening on ${fastify.server.address().port}`);
});
```

## Development and Testing

First, start postgres with:

```
$ docker run --rm -d -p 5432:5432 --name fastify-postgresjs postgres:11-alpine
```

```
$ npm test
```

---
_Source: https://npm.io/package/fastify-postgresjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
