3.0.2 • Published 1 year ago

@obi-tec/manager-postgres-database v3.0.2

Weekly downloads
-
License
Apache License
Repository
github
Last release
1 year ago

Manager Postgres Database

🏁 Content

Install

npm install @obi-tec/manager-postgres-database

See all tags clicking here.

  const { DatabaseConnection } = require('@obi-tec/manager-postgres-database');

Setup Connection

  DatabaseConnection.getInstance(
    'default',
    true,
    connectionSettings : {
      application_name : '',
      min              : 0,
      max              : 1,
      host             : 'localhost',
      port             : '5432',
      user             : 'postgres',
      password         : 'postgres',
      database         : 'postgres'
    },
    enableLogs   : false,
    camelizeKeys : true
  );

Using DatabaseConnection

We are used to using two types of instances: read and write. By the way, when you will use this function, remember to inform which of the options you wanna use.

Example:

  const query  = 'SELECT * FROM user WHERE id = $1';
  const userId = 1;

  await DatabaseConnection.getInstance().connect();

  // passing true value if you want to use database read-only
  // await DatabaseConnection.getInstance(true).connect();

  const user = await DatabaseConnection.getInstance().queryFirstOrNull('getUserById', query, [userId]);
  await DatabaseConnection.getInstance().closeConnection();

Status

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.2

1 year ago

2.2.3

1 year ago

2.1.3

1 year ago

2.2.4

1 year ago

2.1.0

1 year ago

1.0.4

1 year ago

2.0.0

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.0

2 years ago