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
Parameter | Type | Description |
---|---|---|
db_config | { database : string ; host : string ; password : string ; port : number ; user : string ; } | Configuration of database to which to connect. |
db_config.database | string | Name of database to which to connect. |
db_config.host | string | Host serving database. |
db_config.password | string | Password for user. |
db_config.port | number | Port on which database server listens. |
db_config.user | string | User as whom to authenticate. |
Returns
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
Parameter | Type | Description |
---|---|---|
instance | string | Instance identifier of the external resource. |
resource | string | Name of the table to expose as a resource. |
params | Json & object | Parameters 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 ) => void | Error callback. |
callbacks.loading | () => void | Loading callback. |
callbacks.update | (updates , isInit ) => void | Update callback. |
Returns
void
Implementation of
ExternalService.subscribe
unsubscribe()
unsubscribe(instance): void
Unsubscribe from a resource provided by the external service.
Parameters
Parameter | Type | Description |
---|---|---|
instance | string | Instance identifier of the external resource. |
Returns
void
Implementation of
ExternalService.unsubscribe