docs: clarification on minimal example with full error handling
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js, postgresql
調査の方向性
まず、Client、Pool、connect、query、end、error events を扱っている既存のドキュメントセクションを確認します。これらのセクションを issue にある 2 つの最小限の例と比較します。関連するエラーハンドリングの動作と、単一のクエリに Client または Pool を使用する場合のトレードオフが明確に説明されていれば、ドキュメントは完成です。
索引モデルが issue の本文から書いたものです。
説明
The docs somewhat talk about it in pieces, but it wasn't 100% clear what a minimal code example with full error handling looks like, so I was hoping to get some clarity around that. I believe the following are both minimal examples, but I have a few questions surrounding them.
Client example:
import pg from 'pg';
const client = new pg.Client();
await client.connect();
try {
await client.query('SELECT $1::text as message', ['Hello world!']);
} finally {
await client.end();
}
Pool example:
import pg from 'pg';
const pool = new pg.Pool();
try {
await pool.query('SELECT $1::text as message', ['Hello world!']);
} finally {
await pool.end();
}
My couple questions:
- Does either example need an actual event listener for
error, or because I'm callingconnect->query->enddirectly after each other, is it not possible for anerrorevent to actually be emitted? I know in normal case errors that happen during those are rejected with the promise, but I wasn't sure if it was actually possible for anerrorevent to be emitted between say theconnectandquerycalls, etc. - Is there any advantage or disadvantage to using
Pooleven if it's only a single call and will then be torn down? The only advantage I can see is it requires one less line of code since you don't need to explicitly callconnect, but I didn't know if there was other overhead or considered an antipattern*?
* I know instantiating a bunch of pools is an antipattern, but think of a usecase more akin to lambda or something, where it's not possible to keep a pool active, so I'm basically just spinning up some code, running a single query, then spinning everything down. Does using Pool have any negatives for that use case, or does defaulting to Pool over Client make sense?
Thanks for any info/help!
- 主要言語
- JavaScript
- スター
- 13.2k
- フォーク
- 1.4k
- 平均マージ
- 6日 15時間
- マージ済み PR(30日)
- 6
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
brianc/node-postgres のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
brianc/node-postgres#3770 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
brianc/node-postgres#3716 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
brianc/node-postgres#3631 · コメント 1 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
brianc/node-postgres#2857 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
brianc/node-postgres#2433 ·
brianc/node-postgres の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
antfu-collective/icones#398 ·
-
ECmail.com オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
wesbos/burner-email-providers#554 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
components-web-app/docs#92 ·