diff --git a/es/guide/database-integration.md b/es/guide/database-integration.md index 49172c9a..cd6251e6 100755 --- a/es/guide/database-integration.md +++ b/es/guide/database-integration.md @@ -226,12 +226,12 @@ apoc.query('match (n) return n').exec().then( ## PostgreSQL -**Módulo**: [pg](https://github.com/brianc/node-postgres) +**Módulo**: [pg-promise](https://github.com/vitaly-t/pg-promise) **Instalación**
 
-$ npm install pg
+$ npm install pg-promise
 
 
@@ -239,23 +239,16 @@ $ npm install pg
 
-var pg = require('pg');
-var conString = "postgres://username:password@localhost/database";
+var pgp = require("pg-promise")(/*options*/);
+var db = pgp("postgres://username:password@host:port/database");
 
-pg.connect(conString, function(err, client, done) {
-
-  if (err) {
-    return console.error('error fetching client from pool', err);
-  }
-  client.query('SELECT $1::int AS number', ['1'], function(err, result) {
-    done();
-    if (err) {
-      return console.error('error running query', err);
-    }
-    console.log(result.rows[0].number);
-  });
-
-});
+db.one("SELECT $1 AS value", 123)
+    .then(function (data) {
+        console.log("DATA:", data.value);
+    })
+    .catch(function (error) {
+        console.log("ERROR:", error);
+    });