Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

### connectionConfig

- Type: `object`
- Type: `object | Client | Pool`
- Default: `null`
- Required: `true`

Connection configuration object for [node-postgres](https://node-postgres.com/features/connecting#programmatic)
Connection configuration object for [node-postgres](https://node-postgres.com/features/connecting#programmatic).
It can be an existing `pg.Client` or `pg.Pool` instance, too.

### defaultSchema

- Type: `string`
- Default: `'public'`
- Required: `false`

It will be used in objects whose names do not contain a schema name
It will be used in objects whose names do not contain a schema name.

### logging

- Type: `boolean | function`
- Default: `console.info`
- Required: `false`

Option to enable logging in the console or callback of the format `function(...messages) {}` for displaying a message about changes
Option to enable logging in the console or callback of the format `function(...messages) {}` for displaying a message about changes.
5 changes: 4 additions & 1 deletion lib/connection-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
*/
'use strict';

const { Client } = require('pg');
const { Client, Pool } = require('pg');

class ConnectionManager {
static getClient(config) {
if (config instanceof Client || config instanceof Pool) {
return config;
}
return new Client(config);
}

Expand Down
4 changes: 3 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import { Client, Pool } from 'pg';

interface ReferenceOptions {
table: string;
columns: string[];
Expand Down Expand Up @@ -127,7 +129,7 @@ interface ImportOptions {
}

interface DifferOptions {
connectionConfig: object;
connectionConfig: object | Client | Pool;
defaultSchema?: string;
logging?: boolean | Function;
}
Expand Down