1.12.0 • Published 4 months ago

@reelay/mythix-orm-postgresql v1.12.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

mythix-orm-postgresql

Mythix

PostgreSQL database driver for Mythix ORM.

Install

npm i --save mythix-orm-postgresql

Documentation

Documentation can be found at the WIKI.

Documentation for Mythix ORM can be found at the Mythix ORM WIKI.

Usage

const { PostgreSQLConnection } = require('mythix-orm-postgresql');

(async function() {
  let connection = new PostgreSQLConnection({
    bindModels: true,
    models:     [ /* application models */ ],
    logger:     console,
    user:       'database-username',
    password:   'database-password',
    database:   'test-database',
    host:       '127.0.0.1',
    port:       5432,
  });

  await connection.start();

  // run application code

  await connection.stop();
})();

Connection Options

OptionTypeDefault ValueDescription
bindModelsbooleantrueBind the models provided to this connection (see the Mythix ORM Connection Binding article for more information).
connectionTimeoutnumber60000Number of milliseconds to wait for connection.
hoststringundefinedThe domain/host used to connect to the database.
idleTransactionTimeoutnumberundefinedNumber of milliseconds before terminating any session with an open idle transaction.
loggerLogger InterfaceundefinedAssign a logger to the connection. If a logger is assigned, then every query (and every error) will be logged using this logger.
maxPoolConnectionsnumber10Maximum number of clients the connection pool should contain.
modelsArray<Model>undefinedModels to register with the connection (these models will be bound to the connection if the boundModels option is true).
passwordstringundefinedThe password used to connect to the database.
portstring5432The port used to connect to the database.
queryGeneratorQueryGeneratorPostgreSQLQueryGeneratorProvide an alternate QueryGenerator interface for generating SQL statements for PostgreSQL. This is not usually needed, as the SQLiteConnection itself will provide its own generator interface. However, if you want to customize the default query generator, or want to provide your own, you can do so using this option.
queryTimeoutnumber15000Number of milliseconds before a query call will timeout.
statementTimeoutnumber15000Number of milliseconds before a statement in query will time out.
userstringundefinedThe username used to connect to the database.