How to use the slonik.createPool function in slonik

To help you get started, we’ve selected a few slonik examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajus / postloader / src / bin / commands / generate-loaders.js View on Github external
export const handler = async (argv: ArgvType): Promise => {
  // eslint-disable-next-line no-extra-parens, no-new-func
  const filterColumn: ColumnFilterType = (argv.columnFilter ? new Function('tableName', 'columnName', 'columns', argv.columnFilter) : null: any);

  // eslint-disable-next-line no-extra-parens, no-new-func
  const mapTableName: TableNameMapperType = (argv.tableNameMapper ? new Function('tableName', 'columns', argv.tableNameMapper) : null: any);

  const dataTypeMap: DataTypeMapType = argv.dataTypeMap ? JSON.parse(argv.dataTypeMap) : {};

  const pool = await createPool(argv.databaseConnectionUri);

  const columns = await getDatabaseColumns(pool);

  const normalizedColumns = columns
    .filter((column) => {
      if (!filterColumn) {
        return true;
      }

      return filterColumn(column.tableName, column.name, columns);
    })
    .map((column) => {
      return {
        ...column,
        isNullable: column.comment && column.comment.includes('POSTLOAD_NOTNULL') ? false : column.isNullable,
      };

slonik

A Node.js PostgreSQL client with strict types, detailed logging and assertions.

BSD-3-Clause
Latest version published 7 days ago

Package Health Score

83 / 100
Full package analysis