New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trenskow/pged

Package Overview
Dependencies
Maintainers
0
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trenskow/pged

Just a silly little db management and query builder for PostgreSQL.

  • 5.1.48
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@trenskow/pged

Just a silly little db management and query builder for Postgresql.

Usage

const PGed = require('@trenskow/pged');

const db = new PGed({ /* options (see below) */});

const updatedUser = await db.transaction(async () => {

    await db
        .from('users')
        .where({ id: 12 })
        .update({ username: 'myusername' });
    
    return await db
        .from('users')
        .select('id,username')
        .first()
        .where({
            $or: [{
                username: 'myusername'
            }, {
                id: 12
            }]
        });

});

In the above example we wrap our operations in a transaction, which automatically triggers connection to the Postgresql server if not present. The transaction is automatically committed if no error occurs, and automatically rolled back if an error does occur.

Transactions can be inside transactions - the library will figure out when to commit or roll back.

Options

These options are supported when creating a new PGed instance.

NameTypeDescriptionValuesDefault
casingObjectSee below
casing.dbStringThe casing to use in the db.Any supported by the caseit package.snake
casing.jsStringThe casing to use in js.Same as abovecamel

PostgreSQL Connection

To set connection parameters use environment variables or do as below.

const PGed = require('@trenskow/pged');

PGed.pg = { /* Options */ };

const db = new PGed({ /* options */ })

See the pg package for available environment variables and options.

License

See LICENSE.

Keywords

FAQs

Package last updated on 18 Jan 2025

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc