Skip to main content

PostgresExternalService

An ExternalService wrapping a PostgreSQL database.

Expose the tables of a PostgreSQL database as resources in the Skip runtime.

Remarks

Subscription params must include a field key whose value is an object with a string field col identifying the table column that should be used as the key in the resulting collection, and a field type whose value is one of INTEGER, BIGINT, SERIAL, BIGSERIAL, or TEXT.

Implements

  • ExternalService

Constructors

new PostgresExternalService()

new PostgresExternalService(db_config): PostgresExternalService

Parameters

ParameterTypeDescription
db_config{ database: string; host: string; password: string; port: number; user: string; }Configuration of database to which to connect.
db_config.databasestringName of database to which to connect.
db_config.hoststringHost serving database.
db_config.passwordstringPassword for user.
db_config.portnumberPort on which database server listens.
db_config.userstringUser as whom to authenticate.

Returns

PostgresExternalService

Methods

isConnected()

isConnected(): boolean

Returns

boolean


shutdown()

shutdown(): void

Shutdown the external service.

Returns

void

Implementation of

ExternalService.shutdown

subscribe()

subscribe(
instance,
resource,
params,
callbacks): void

Subscribe to a resource provided by the external service.

Parameters

ParameterTypeDescription
instancestringInstance identifier of the external resource.
resourcestringName of the table to expose as a resource.
paramsJson & objectParameters of the external resource; must include a field key whose value is an object with a string field col identifying the table column that should be used as the key in the resulting collection, and a field type whose value is one of INTEGER, BIGINT, SERIAL, BIGSERIAL, or TEXT.
callbacks{ error: (error) => void; loading: () => void; update: (updates, isInit) => void; }Callbacks to react on error/loading/update.
callbacks.error(error) => voidError callback.
callbacks.loading() => voidLoading callback.
callbacks.update(updates, isInit) => voidUpdate callback.

Returns

void

Implementation of

ExternalService.subscribe

unsubscribe()

unsubscribe(instance): void

Unsubscribe from a resource provided by the external service.

Parameters

ParameterTypeDescription
instancestringInstance identifier of the external resource.

Returns

void

Implementation of

ExternalService.unsubscribe