|
|
|
|
|
by twomoonsbysurf
1543 days ago
|
|
Super cool, looks great. Interesting to see you built it with Typescript. I was wondering-- and I know this is a long story, but I am curious: How does one go about building a PostgreSQL driver for NodeJS in Typescript? How do you design and begin that sort of thing? What sort of knowledge resources did you rely on (i.e. documentation, other references)? I googled 'database driver' to get a definition: "A database driver is a computer program that implements a protocol (ODBC or JDBC) for a database connection. The driver works like an adaptor which connects a generic interface to a specific database vendor implementation." |
|
I did not built it with Typescript, just plain js - I don't use Typescript at all(not my cup of tee), but a kind soul (thanks @minigugus) contributed the typings ;)
I actually began it out of curiosity and because I was missing features in the current options. I had been using a wrapper around pg-promise to give me the API i wanted for quite a while, and one day when going through the PostgreSQL documentation I landed on the protocol (https://www.postgresql.org/docs/current/protocol.html) pages. Now the PostgreSQL documentation might seem daunting at first, but once you figure out the structure and semantics it's such an insanely good resource. I had the first POC version working over a weekend, and from there it was about 80% of the way to support all the things I needed. Now the Postgres protocol is actually fairly simple, and I suppose that's why other databases have chosen to use it as well (eg. Postgres.js also works with cockroachdb). I would love to write a longer post about the progress at some point, but I haven't found the time for it yet.