2.0.3 • Published 9 months ago

@hashirrao/postgresql-general-backend v2.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

PostgreSQL Query Utility: @hashirrao/postgresql-general-backend

A simple and efficient Node.js utility for performing CRUD operations on PostgreSQL databases. This package simplifies database interaction by abstracting common query patterns, making development faster and cleaner.


Installation

npm install @hashirrao/postgresql-general-backend

or

yarn add @hashirrao/postgresql-general-backend

Insert Data

Quickly add new rows to a table.

Retrieve Data

Fetch records with filtering, sorting, pagination, and column selection.

Update Data

Modify rows based on specified conditions.

Hard Delete

Remove rows from the database.

Usage

Import the Package

const { insertData, getData, updateData, deleteData, hardDeleteData } = require('@hashirrao/postgresql-general-backend');

Set Up Connection

const connectionObj = {
    user: 'your-username',
    host: 'your-host',
    database: 'your-database',
    password: 'your-password',
    port: 5432,
};

Examlples

Insert Data

const tableName = 'users';
const data = { name: 'John Doe', email: 'john.doe@example.com' };

insertData(connectionObj, tableName, data)
    .then(response => console.log(response))
    .catch(error => console.error(error));

Retrieve Data

getData(connectionObj, 'users', ['id', 'name'], [{ column_name: 'is_deleted', operation: '=', value: false }], 'name', 10, 0)
    .then(response => console.log(response))
    .catch(error => console.error(error));

Update Data

updateData(connectionObj, 'users', { name: 'Jane Doe' }, [{ column_name: 'id', operation: '=', value: 1 }])
    .then(response => console.log(response))
    .catch(error => console.error(error));

Delete

deleteData(connectionObj, 'users', [{ column_name: 'id', operation: '=', value: 1 }])
    .then(response => console.log(response))
    .catch(error => console.error(error));

Github

Visit GitHub for the source code.

2.0.3

9 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

12 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago