Skip to content

Docs: document client.release() #1302

Closed
@abenhamdine

Description

@abenhamdine

Hi Brian,

I just upgraded from [email protected] to [email protected], and noticed something :

  • in pg versions <6, pg.client has not attached release() method.
  • since 6.0.0 (or perhaps later ?), client.release() exists.

Therefore I presume that it's no longer necessary to use the following pattern (from the current version of wiki) :

pool.connect(function(err, client, release) {

  client.query('SELECT $1::text as name', ['foo'], function(err, result) {
    release();
    console.log(result.rows[0].name); // output: foo
  });
});

and now with pg >=6, we can safely use this shorter way ?

pool.connect(function(err, client) {

  client.query('SELECT $1::text as name', ['foo'], function(err, result) {
    // note we use directly the release() method of client object
    client.release();
    console.log(result.rows[0].name); // output: foo
  });
});

It seems to work fine with my code, but I would want to be sure that is the proper way to release the client and that client.release() is part of the public API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions