Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pasupulaphani committed Feb 10, 2017
2 parents c4b1d23 + 88a3758 commit 17e4590
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ node_js:
- 'node'
before_script:
- psql -c 'create database travis_ci_test;' -U postgres
before_install:
- sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update -qq
- sudo apt-get install -y -qq yarn
install: yarn
cache:
yarn: true
directories:
- node_modules
env:
- DATABASE_URL=postgres://postgres@localhost:5432/travis_ci_test
after_success:
Expand Down
12 changes: 6 additions & 6 deletions docs/PgPool.html
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ <h5>Returns:</h5>



<h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(commandName, commandArgs)</span><span class="type-signature"> &rarr; {promise}</span></h4>
<h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(queryText, arrayValues)</span><span class="type-signature"> &rarr; {promise}</span></h4>



Expand Down Expand Up @@ -1468,7 +1468,7 @@ <h4 class="name" id="query"><span class="type-signature"></span>query<span class


<div class="description">
<p>Send Postgres instructions</p>
<p>Run Postgres query https://github.com/brianc/node-postgres/wiki/Client#querystring-querytext-array-values-optional-function-callback-query</p>
</div>


Expand Down Expand Up @@ -1506,7 +1506,7 @@ <h5>Parameters:</h5>

<tr>

<td class="name"><code>commandName</code></td>
<td class="name"><code>queryText</code></td>


<td class="type">
Expand All @@ -1522,14 +1522,14 @@ <h5>Parameters:</h5>



<td class="description last"><p>Name of the command</p></td>
<td class="description last"><p>sql query</p></td>
</tr>



<tr>

<td class="name"><code>commandArgs</code></td>
<td class="name"><code>arrayValues</code></td>


<td class="type">
Expand All @@ -1545,7 +1545,7 @@ <h5>Parameters:</h5>



<td class="description last"><p>Args sent to the command</p></td>
<td class="description last"><p>array values</p></td>
</tr>


Expand Down
5 changes: 3 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ <h3>Sponsors</h3><p>No sponsors yet! Will you be the first?</p>
<a href="https://flattr.com/profile/pasupulaphani" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button"></a>
<!-- [![PayPal donate button](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://phaninder.com/paypal "Donate to this project using Paypal") -->
<!-- [![Bitcoin donate button](https://img.shields.io/badge/bitcoin-donate-yellow.svg)](https://phaninder.com/bitcoin "Donate once-off to this project using Bitcoin") -->
<!-- [![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)](https://phaninder.com/wishlist "Buy an item on our wishlist for us") --></p>
<!-- [![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)](https://phaninder.com/wishlist "Buy an item on our wishlist for us") -->
<a href='https://pledgie.com/campaigns/33355'><img alt='Click here to lend your support to: simple-node-redis-cache and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/33355.png?skin_name=chrome' border='0' ></a></p>
<h3>Contributors</h3><p>These amazing people have contributed to/reviewed this project:</p>
<ul>
<li><a href="https://github.com/oliverbrooks">Oliver Brooks</a></li>
</ul>
<p><a href="https://github.com/pasupulaphani/node-pg-connection-pool/blob/master/CONTRIBUTING.md">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a></p>
<p><br /></p>
<h2><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-57413413-3', 'auto');ga('send', 'pageview');</script></h2></article>
<h2><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-57413413-7', 'auto');ga('send', 'pageview');</script></h2></article>
</section>


Expand Down
10 changes: 5 additions & 5 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ <h1 class="page-title">index.js</h1>
};

/**
* Send Postgres instructions
* Run Postgres query https://github.com/brianc/node-postgres/wiki/Client#querystring-querytext-array-values-optional-function-callback-query
*
* @param {string} commandName - Name of the command
* @param {array} commandArgs - Args sent to the command
* @param {string} queryText - sql query
* @param {array} arrayValues - array values
* @returns {promise} Promise resolve with the result or Error
*/
PgPool.prototype.query = function (queryString) {
PgPool.prototype.query = function (queryText, arrayValues) {

return this.pool.acquire()
.then(client => {

return client.query(queryString)
return client.query(queryText, arrayValues)
.then(result => {

this.pool.release(client);
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ const PgPool = module.exports = function (options) {
};

/**
* Send Postgres instructions
* Run Postgres query https://github.com/brianc/node-postgres/wiki/Client#querystring-querytext-array-values-optional-function-callback-query
*
* @param {string} commandName - Name of the command
* @param {array} commandArgs - Args sent to the command
* @param {string} queryText - sql query
* @param {array} arrayValues - array values
* @returns {promise} Promise resolve with the result or Error
*/
PgPool.prototype.query = function (queryString) {
PgPool.prototype.query = function (queryText, arrayValues) {

return this.pool.acquire()
.then(client => {

return client.query(queryString)
return client.query(queryText, arrayValues)
.then(result => {

this.pool.release(client);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-pg-connection-pool",
"version": "0.5.0",
"version": "0.6.0",
"description": "Connection pool for node-postgres with generic-pool support",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions test/pg_connection_pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,15 @@ describe("PgPool", () => {

it("should execute given query", () => {

return pool.query("SELECT 1;")
.then(res => res.rows[0]["?column?"])
return pool.query("SELECT 1 AS number;")
.then(res => res.rows[0]["number"])
.should.eventually.be.eql(1);
});

it("should execute given query with arrayValues", () => {

return pool.query("SELECT $1::int AS number;", ["1"])
.then(res => res.rows[0]["number"])
.should.eventually.be.eql(1);
});

Expand Down

0 comments on commit 17e4590

Please sign in to comment.