Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brainsights/postgres-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brainsights/postgres-wrapper - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

27

index.js
const pg = require("pg");
const SQL = require("sql-template-strings");
const debug = require("debug")("postgres-wrapper");
const uuid = require("uuid");
let types = pg.types;
types.setTypeParser(20, function(val) {
return parseInt(val)
});
const __ = new WeakMap();

@@ -17,3 +23,4 @@

__.set(proxy, {
revoke: revoke
revoke: revoke,
id: uuid.v4(),
});

@@ -29,3 +36,3 @@ return proxy;

client = await pool.connect();
debug("acquire client");
debug(`${this.id} acquire client`);
} catch(e) {

@@ -40,2 +47,3 @@ throw new Error(`unable to get database client: ${e.message}`)

result = await __.get(this).client.query(...args);
debug(`${this.id} query`)
} catch(e) {

@@ -50,6 +58,11 @@ throw new Error(`query failed: ${e.message}`)

{
debug("release client");
debug(`${__.get(this).id} release client`);
__.get(this).client.end();
__.get(this).revoke();
}
get id()
{
return __.get(this).id;
}
};

@@ -70,7 +83,7 @@

await super.query(SQL`BEGIN`);
debug("begin transaction");
debug(`${this.id} begin transaction`);
} catch(e) {
throw new Error(`unable to start transaction: ${e.message}`);
__.get(this).revoke();
debug("revoke transaction object");
debug(`${this.id} revoke transaction object`);
}

@@ -86,3 +99,3 @@ __.get(this).begin = true;

await this.query(SQL`COMMIT`);
debug("commit transaction");
debug(`${this.id} commit transaction`);
super.end();

@@ -94,3 +107,3 @@ }

await this.query(SQL`ROLLBACK`);
debug("abort transaction");
debug(`${this.id} abort transaction`);
super.end();

@@ -97,0 +110,0 @@ }

{
"name": "@brainsights/postgres-wrapper",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -15,5 +15,5 @@ "main": "index.js",

"pg": "^6.1.4",
"pg-native": "^1.10.0",
"sql-template-strings": "^2.2.2"
"sql-template-strings": "^2.2.2",
"uuid": "^3.0.1"
}
}
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