========== PostgreSQL ========== - `PostgreSQL Server `_ - **npm** i *@pi-r/postgres* Interface ========= .. code-block:: typescript import type { QueryArrayConfig, PoolConfig } from "pg"; interface PostgresDataSource extends DbDataSource { source: "postgres"; credential: string | PostgresCredential; query?: string | QueryArrayConfig; params?: unknown[]; } interface PostgresCredential extends ServerAuth, PoolConfig { password?: string | (() => string | Promise); } Pool ---- .. code-block:: typescript import type { PoolConfig } from "pg"; interface PoolConfig { min?: number; // min max?: number; // max idle?: number; // idleTimeoutMillis timeout?: number; // connectionTimeoutMillis } Authentication ============== - `Connection `_ :: { "dataSource": { "uri": "postgresql://:@localhost:5432/", // Alias for "connectionString" /* OR */ "credential": "main", // squared.db.json /* OR */ "credential": { "host": "localhost", // Required "port": 5432, "user": "**********", // Required "password": "**********", "database": "example" } } } Example usage ============= - `Query `_ :: { "selector": "img", "type": "attribute", "dataSource": { "source": "postgres", "credential": {/* Authentication */}, "query": "SELECT * FROM table WHERE id = $1 AND value = $2", "query": "./path/to/statement.sql", // Extension ".sql" (settings.directory.sql + users/username/?) "params": [1, "escaped"], /* Result: { "item_src": "postgres.png", "item_alt": "PostgreSQL" } */ "value": { "src": "item_src", "alt": "item_alt" }, "usePool": true, "options": { "min": 0, "max": 10 } } }