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

pg-promise

Package Overview
Dependencies
Maintainers
1
Versions
629
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-promise - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

8

index.js

@@ -38,3 +38,3 @@ // Cannot declare 'use strict' here, because queryResult

var lib = function (cn) {
if(!$isEmptyObject(this)){
if (!$isEmptyObject(this)) {
// This makes it easy to locate the most common mistake -

@@ -195,3 +195,3 @@ // skipping keyword 'new' when calling: var db = new pgp(cn);

if(!$isEmptyObject(tx)){
if (!$isEmptyObject(tx)) {
// This makes it easy to locate the most common mistake -

@@ -326,3 +326,3 @@ // skipping keyword 'new' when calling: var tx = new db.tx(cn);

// Checks if the object is empty (has no properties);
function $isEmptyObject(obj){
function $isEmptyObject(obj) {
return Object.keys(obj).length === 0;

@@ -404,3 +404,3 @@ }

if (qrm & queryResult.none) {
data = null;
data = (qrm & queryResult.many) ? [] : null;
} else {

@@ -407,0 +407,0 @@ reject("No rows returned from query: '" + query + "'");

{
"name": "pg-promise",
"version": "0.2.1",
"version": "0.2.2",
"description": "PG + Promise made easy, with transactions support.",

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

@@ -17,7 +17,9 @@ # Introduction

```javascript
var pgpLib = require('pg-promise'); // loading the library
// Loading the library:
var pgpLib = require('pg-promise');
```
### 2. Initialize the library
```javascript
var pgp = pgpLib(/*options*/); // initializing the library, with optional global settings
// Initializing the library, with optional global settings:
var pgp = pgpLib(/*options*/);
```

@@ -87,2 +89,4 @@ You can pass additional ```options``` parameter when initilizing the library (see chapter Advanced for details).

To better understand the effect of such different calls, see section <b>Understanding the query result</b> below.
Each of the query calls returns a [Promise] object, as shown below, to be used in the standard way.

@@ -98,2 +102,15 @@ And when the expected and actual results do not match, the call will be rejected.

```
##### Understanding the query result
Each query function resolves <b>data</b> according to the <b>Query Result Mask</b> that was used, and must be handled accordingly, as explained below.
* `none` - <b>data</b> is `null`. If the query returns any kind of data, it is rejected.
* `one` - <b>data</b> is a single object. If the query returns no data or more than one row of data, it is rejected.
* `many` - <b>data</b> is an array of objects. If the query returns no rows, it is rejected.
* `one` | `none` - <b>data</b> is `null`, if no data was returned; or a single object, if there was one row of data returned. If the query returns more than one row of data, the query is rejected.
* `many` | `none` - <b>data</b> is an array of objects. When no rows are returned, <b>data</b> is an empty array.
If you try to specify `one` | `many` in the same query, such query will be rejected without executing it, telling you that such mask is not valid.
> This is all about writing robust code, when the client declaratively specifies what kind of data it is ready to handle, leaving the burden of all extra checks to the library.
### Functions and Procedures

@@ -100,0 +117,0 @@ In PostgreSQL stored procedures are just functions that usually do not return anything.

Sorry, the diff of this file is not supported yet

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