Skip to content

Commit

Permalink
Add details about differences between js and native bindings (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
abenhamdine authored and brianc committed Aug 2, 2016
1 parent 4e77464 commit 9f955c4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

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

Expand Down

0 comments on commit 9f955c4

Please sign in to comment.