Class: Postgres

arpen/services/postgres~ Postgres

Postgres service

pg module is required

Add to your config
// PostgreSQL servers
postgres: {
  main: {
    host: 'localhost',
    port: 5432,
    user: 'username',
    password: 'password',
    database: 'dbname',
    min: 10,
    max: 100,
  },
},

new Postgres(config, logger, runner, util)

Create the service
Parameters:
Name Type Description
config object Config service
logger Logger Logger service
runner Runner Runner service
util Util Util service

Members


<static> provides :string

Service name is 'postgres'
Type:
  • string

<static> requires :Array.<string>

Dependencies as constructor arguments
Type:
  • Array.<string>

<static> lifecycle :string

This service is a singleton
Type:
  • string

<static> datetimeFormat :string

Format of date/time string
Type:
  • string

Methods


<async> connect(name)

Obtain Postgres client
Parameters:
Name Type Default Description
name string 'main' Server name in config
Returns:
Resolves to connected PostgresClient instance
Type
Promise

<async> exec(filename, instance)

Execute SQL file
Parameters:
Name Type Default Description
filename string
instance string | object main
Returns:
Type
Promise