🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@obi-tec/manager-postgres-database

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@obi-tec/manager-postgres-database

A simple library to help developers to manage connections and queries on postgres database

3.0.2
latest
Source
npm
Version published
Maintainers
3
Created
Source

Manager Postgres Database

🚀 A simple library to help developers to manage connections and queries on postgres database

🏁 Content


Install

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

See all tags clicking here.


# How to Use In your file.js, import the dependency and extract the DatabaseConnection.
  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

🚧 Open for contribuitions... 🚧

Keywords

node-js

FAQs

Package last updated on 06 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts