diff --git a/.travis.yml b/.travis.yml index ec15773..37111f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "9" - "8" - "7" - "6" diff --git a/README.md b/README.md index 8833436..50c3bfe 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Database-js wrapper for PostgreSQL ## About -Database-js-mysql is a wrapper around the [node-postgres](https://github.com/brianc/node-postgres) package by Brian Carlson. It is intended to be used with the [database-js](https://github.com/mlaanderson/database-js) package. However it can also be used in stand alone mode. The only reason to do that would be to use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Database-js-postgres is a wrapper around the [node-postgres](https://github.com/brianc/node-postgres) package by Brian Carlson. It is intended to be used with the [database-js](https://github.com/mlaanderson/database-js) package. However it can also be used in stand alone mode. The only reason to do that would be to use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). ## Usage ### Stand Alone ~~~~ diff --git a/package-lock.json b/package-lock.json index 77aa333..2cc9533 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "database-js-postgres", - "version": "1.1.1", + "version": "1.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -14,6 +14,12 @@ "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.1.tgz", "integrity": "sha1-Iqk2kB4wKa/NdUfrRIfOtpejvwg=" }, + "database-js": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/database-js/-/database-js-3.0.2.tgz", + "integrity": "sha512-YoCw6q95dwzbD/3PlZm6+CcxJY8QbEvbEt5bRCUVdskyT5j97Ofjt77in6GpCbxDUbKBZ7eGzlyJ7pLPH7raAg==", + "dev": true + }, "packet-reader": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.3.1.tgz", diff --git a/package.json b/package.json index cf670a4..e7f86ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "database-js-postgres", - "version": "1.1.1", + "version": "1.1.2", "description": "Database-js wrapper for PostgreSQL", "main": "index.js", "scripts": { @@ -21,6 +21,9 @@ }, "homepage": "https://github.com/mlaanderson/database-js-postgres#readme", "dependencies": { - "pg": "^7.0.2" + "pg": "^8.5.1" + }, + "devDependencies": { + "database-js": "^3.0.2" } } diff --git a/test.js b/test.js index cca183f..2b9f551 100644 --- a/test.js +++ b/test.js @@ -8,26 +8,26 @@ var Connection = Postgres.open({ Database: 'test' }); -var promises = []; -promises.push(Connection.execute('DROP TABLE IF EXISTS test1; CREATE TABLE test1 (key character varying(255), value character varying(1024));').then(() => { - promises.push(Connection.execute("INSERT INTO test1 VALUES('name', 'Michael Anderson');").then(() => { - promises.push(Connection.query("SELECT * FROM test1 WHERE key = 'name';").then(data => { - if (data.length != 1) { - console.error('Invalid data returned'); - Connection.execute('DROP TABLE test1;').then(() => { +function handleError(error) { + console.log("ERROR:", error); + process.exit(1); +} + +Connection.execute('DROP TABLE IF EXISTS test1;').then(() => { + Connection.execute('CREATE TABLE test1 (fl_name varchar(32), fl_value varchar(32));').then(() => { + Connection.execute("INSERT INTO test1 VALUES('name', 'Michael Anderson');").then(() => { + Connection.query("SELECT * FROM test1 WHERE fl_name = 'name';").then(data => { + if (data.length != 1) { + return handleError(new Error("Invalid data returned")); + } + console.log(data); + Connection.execute('DROP TABLE IF EXISTS test1;').then(() => { Connection.close().then(() => { - process.exit(1); - }); - }) - } - })); - })); -})); + process.exit(0); + }).catch(handleError); + }).catch(handleError); + }).catch(handleError); + }).catch(handleError); + }).catch(handleError); +}).catch(handleError); -Promise.all(promises).then(() => { - Connection.execute('DROP TABLE IF EXISTS test1;').then(() => { - Connection.close().then(() => { - process.exit(0); - }); - }); -});