# jovo-db-postgresql

> > To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-postgresql

Latest version **3.6.1** (published 2022-02-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install jovo-db-postgresql
pnpm add jovo-db-postgresql
yarn add jovo-db-postgresql
bun add jovo-db-postgresql
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.6.1 |
| Published | 2022-02-17 |
| First published | 2020-12-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jovotech |
| Maintainers | jovotech |

## Links

- npm: https://www.npmjs.com/package/jovo-db-postgresql
- npm.io page: https://npm.io/package/jovo-db-postgresql

## Dependencies (3)

- [pg](https://npm.io/package/pg.md) ^8.5.0
- [jovo-core](https://npm.io/package/jovo-core.md) ^3.6.1
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

## Recent versions

- 3.6.1 (latest) — 2022-02-17
- 3.6.0 — 2021-11-18
- 3.5.1 — 2021-03-26
- 3.5.0 — 2021-02-22
- 3.4.1 — 2021-02-09
- 3.4.0 — 2021-02-04
- 3.3.1 — 2021-01-27
- 3.3.0 — 2020-12-03

## README

# PostgreSQL Database Integration

> To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-postgresql

Learn how to use PostgreSQL as your app's database to store user specific data.

* [Installation](#installation)

## Installation

Download the package like this:

```sh
$ npm install --save jovo-db-postgresql
```

PostgreSQL database integration can be enabled in the `src/app.js` file like this:

```javascript
// @language=javascript

// src/app.js

const { PostgreSQL } = require('jovo-db-postgresql');

// Enable DB after app initialization
app.use(new PostgreSQL());

// @language=typescript

// src/app.ts

import { PostgreSQL } from 'jovo-db-postgresql';

// Enable DB after app initialization
app.use(new PostgreSQL());
```

In your `config.js` file, you can set the `db` configuration like this:

```javascript
// @language=javascript

// src/config.js

module.exports = {
  db: {
    PostgreSQL: {
      tableName: 'yourTableName',
      connection: {
        host: '',
        port: 3000,
        user: '',
        password: '',
        database: '',
      },
    },
  },

  // ...
};

// @language=typescript

// src/config.ts

const config = {
  db: {
    PostgreSQL: {
      tableName: 'yourTableName',
      connection: {
        host: '',
        port: 3000,
        user: '',
        password: '',
        database: '',
      },
    },
  },

  // ...
};
```

This is the default configuration for PostgreSQL, if not specified otherwise:

```javascript
// @language=javascript

// src/config.js

module.exports = {
  db: {
    PostgreSQL: {
      tableName: 'users',
      primaryKeyColumn: 'userId',
      dataColumnName: 'userData',
      connection: {},
    },
  },

  // ...
};

// @language=typescript

// src/config.ts

const config = {
  db: {
    PostgreSQL: {
      tableName: 'users',
      primaryKeyColumn: 'userId',
      dataColumnName: 'userData',
      connection: {},
    },
  },

  // ...
};
```

Once the configuration is done, the PostgreSQL database integration will create a table in your Database on the first read/write attempt.

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