Add details about differences between js and native bindings (#1096)

This commit is contained in:
Arnaud Benhamdine 2016-08-02 16:21:31 +02:00 committed by Brian C
parent 4e77464bfc
commit 9f955c4348

View File

@ -139,7 +139,17 @@ var Pool = pg.Pool // good! a pool bound to the native client
var Client = pg.Client // good! this client uses libpq bindings var Client = pg.Client // good! this client uses libpq bindings
``` ```
node-postgres abstracts over the pg-native module to provide exactly the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum; however, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing! #### API differences
node-postgres abstracts over the pg-native module to provide the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum.
However, currently some differences remain, especially :
* the error object in pg-native is different : notably, the information about the postgres error code is not present in field `code` but in the field `sqlState` , and the name of a few other fields is different (see https://github.com/brianc/node-postgres/issues/938, https://github.com/brianc/node-postgres/issues/972).
So for example, if you rely on error.code in your application, your will have to adapt your code to work with native bindings.
* the notification object has a few less properties (see https://github.com/brianc/node-postgres/issues/1045)
* column objects have less properties (see https://github.com/brianc/node-postgres/issues/988)
* the modules https://github.com/brianc/node-pg-copy-streams and https://github.com/brianc/node-pg-query-stream do not work with native bindings (you will have to require 'pg' to use them).
Thus, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing!
## Features ## Features