Promise API for JavaScript callers, exported by the shadow-cljs :node build.
Promise API for JavaScript callers, exported by the shadow-cljs :node build.
(connect config)connect({hostname, port, username, password, database}) resolves to a client once the server is ready for queries. For TLS, add ssl: 'disable', 'prefer', 'require', 'verify-ca' or 'verify-full' (or true, for 'verify-full'), and as needed sslRootCert, sslCert and sslKey (each a file name, PEM text or a Buffer), sslServername, sslNegotiation: 'direct', and sslOptions for tls.connect.
connect({hostname, port, username, password, database}) resolves to a
client once the server is ready for queries. For TLS, add ssl: 'disable',
'prefer', 'require', 'verify-ca' or 'verify-full' (or true, for
'verify-full'), and as needed sslRootCert, sslCert and sslKey (each a file
name, PEM text or a Buffer), sslServername, sslNegotiation: 'direct', and
sslOptions for tls.connect.(listen client channel)listen(client or pool, channel) is an async iterable of the notifications sent on a LISTEN channel, each {channel, payload, pid}, for for-await. Leaving the loop (break) stops listening. It rejects if the connection drops or the listener falls 1000 notifications behind.
listen(client or pool, channel) is an async iterable of the notifications
sent on a LISTEN channel, each {channel, payload, pid}, for for-await.
Leaving the loop (break) stops listening. It rejects if the connection
drops or the listener falls 1000 notifications behind.(notify client channel payload)notify(client or pool, channel, payload) sends payload, a string, to the channel's listeners with pg_notify.
notify(client or pool, channel, payload) sends payload, a string, to the channel's listeners with pg_notify.
(pool config)pool({hostname, port, username, password, database, maxSize}) returns a pool of up to maxSize (default 10) clients that connect when queries need them. query and stream take it in place of a client. It takes connect's TLS settings too.
pool({hostname, port, username, password, database, maxSize}) returns a
pool of up to maxSize (default 10) clients that connect when queries need
them. query and stream take it in place of a client. It takes connect's
TLS settings too.(query client sql)(query client sql params)query(client or pool, sql, params?) resolves to an array of row objects. params is an array of the values of $1, $2, ... in sql.
query(client or pool, sql, params?) resolves to an array of row objects. params is an array of the values of $1, $2, ... in sql.
(stream client sql)(stream client sql params)stream(client or pool, sql, params?) is an async iterable of row objects, for for-await and Readable.from. The server sends rows in batches, so leaving early (break, or a destroyed stream) stops it and lets the next query run; on a pool, it frees the connection. A reader that falls behind pauses the connection, so the server waits for it. A failed query rejects.
stream(client or pool, sql, params?) is an async iterable of row objects, for for-await and Readable.from. The server sends rows in batches, so leaving early (break, or a destroyed stream) stops it and lets the next query run; on a pool, it frees the connection. A reader that falls behind pauses the connection, so the server waits for it. A failed query rejects.
(unlisten client channel)unlisten(client or pool, channel) ends every listen on channel, and resolves once the server has stopped sending its notifications.
unlisten(client or pool, channel) ends every listen on channel, and resolves once the server has stopped sending its notifications.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |