當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript pg.Pool類代碼示例

本文整理匯總了TypeScript中pg.Pool的典型用法代碼示例。如果您正苦於以下問題:TypeScript Pool類的具體用法?TypeScript Pool怎麽用?TypeScript Pool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Pool類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Pool

 (async () => {
   const pgPool = new Pool(pgConfig);
   pgPool.on('error', err => {
     // tslint:disable-next-line no-console
     console.error('PostgreSQL client generated error: ', err.message);
   });
   const { getGraphQLSchema } = getPostgraphileSchemaBuilder(pgPool, schemas, postgraphileOptions);
   await getGraphQLSchema();
   if (!watchPg) {
     await pgPool.end();
   }
 })().then(null, e => {
開發者ID:calebmer,項目名稱:postgraphql,代碼行數:12,代碼來源:cli.ts

示例2: Pool

export const createPoolConnection = (conf: any): DBConnectionsPool => {
    const pool: Pool = new Pool(conf);
    return {
        query(q) {
            return pool.query(q);
        },
        connect() {
            return pool.connect();
        },
        stop() {
            return pool.end();
        }
    };
};
開發者ID:zorro-del-caribe,項目名稱:ship-hold,代碼行數:14,代碼來源:connections.ts

示例3: Date

    (async () => {
        const client = await pool.connect();

        try {
            for (const message of messages) {
                await client.query(
                    sql,
                    [
                        message.body,
                        message.expiresAt,
                        message.group,
                        message.localId,
                        message.publicId,
                        message.source,
                        message.title,
                        message.url,
                        new Date(),
                        userId,
                        message.badge,
                    ],
                );
            }
            await client.query('COMMIT');
        } catch (e) {
            await client.query('ROLLBACK');
            throw e;
        } finally {
            client.release();
        }
    })().catch((e) => console.error(e.stack));
開發者ID:lovett,項目名稱:notifier,代碼行數:30,代碼來源:db.ts

示例4: checkExchangeSimple

export function checkExchangeSimple(exchange: Exchange, exchange_details: string[]): Promise < any > {
  return pool.query(
    // tslint:disable-next-line:max-line-length
    "INSERT INTO exchanges (exchange_name, pairs) VALUES ($1, $2) ON CONFLICT (exchange_name) DO UPDATE SET exchange_name = $1, pairs = $2", [exchange.name, exchange_details]
  ).catch(e => {
    logger.logError("checkExchange query", e);
  });
}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:8,代碼來源:database.ts

示例5: checkAsset

export function checkAsset(ticker: string, asset_details: string[], exchange: string): Promise < any > {
  ticker = getTicker(ticker, exchange.toLowerCase());
  if (assets[ticker]) {
    // tslint:disable-next-line:max-line-length
    return pool.query("INSERT INTO assets (asset_ticker, asset_name, asset_website, asset_total_supply, exchanges) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (asset_ticker) DO UPDATE SET asset_name = $2, asset_website=$3, asset_total_supply=$4, exchanges=$5", [ticker, assets[ticker].name, assets[ticker].website_url, assets[ticker].total_supply, asset_details])
    .catch(e => {
      logger.logError("checkAsset query", e);
    });
  } else {
    // tslint:disable-next-line:max-line-length
    return pool.query("INSERT INTO assets (asset_ticker, exchanges) VALUES ($1, $2) ON CONFLICT (asset_ticker) DO UPDATE SET exchanges = $2", [ticker, asset_details])
    .catch(e => {
      logger.logError("checkAsset query", e);
    });
  }

}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:17,代碼來源:database.ts

示例6: checkExchangePairSimple

export function checkExchangePairSimple(base: string, quote: string, exchange: string): Promise < any > {
  base = getTicker(base, exchange.toLowerCase());
  quote = getTicker(quote, exchange.toLowerCase());
  // tslint:disable-next-line:max-line-length
  return pool.query("INSERT INTO exchange_pairs (exchange_id, pair_id) SELECT (SELECT exchange_id FROM exchanges WHERE exchange_name = $1), (SELECT p.pair_id FROM pairs p WHERE p.base_id = (SELECT asset_id FROM assets WHERE asset_ticker = $2) AND p.quote_id = (SELECT asset_id FROM assets WHERE asset_ticker = $3)) ON CONFLICT (exchange_id, pair_id) DO NOTHING", [exchange, base, quote])
    .catch(e => {
      logger.logError("checkExchangePair query base: " + base + " quote: " + quote, e);
    });
}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:9,代碼來源:database.ts

示例7: checkExchangePair

export function checkExchangePair(base: string, quote: string, precision: number, active: boolean, exchange: string): Promise < any > {
  base = getTicker(base, exchange.toLowerCase());
  quote = getTicker(quote, exchange.toLowerCase());
  // tslint:disable-next-line:max-line-length
  return pool.query("INSERT INTO exchange_pairs (exchange_id, pair_id, price_precision, active) SELECT (SELECT exchange_id FROM exchanges WHERE exchange_name = $1), (SELECT p.pair_id FROM pairs p WHERE p.base_id = (SELECT asset_id FROM assets WHERE asset_ticker = $2) AND p.quote_id = (SELECT asset_id FROM assets WHERE asset_ticker = $3)), $4, $5 ON CONFLICT (exchange_id, pair_id) DO UPDATE SET price_precision = $4, active = $5", [exchange, base, quote, precision, active])
    .catch(e => {
      logger.logError("checkExchangePair query base: " + base + " quote: " + quote, e);
    });
}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:9,代碼來源:database.ts

示例8: checkPair

export function checkPair(base: string, quote: string, pair_details: string[], exchange: string): Promise < any > {
  base = getTicker(base, exchange.toLowerCase());
  quote = getTicker(quote, exchange.toLowerCase());
  // tslint:disable-next-line:max-line-length
  return pool.query("INSERT INTO pairs (base_id, quote_id, exchanges, base, quote) SELECT (SELECT asset_id FROM assets WHERE asset_ticker = $1), (SELECT asset_id FROM assets WHERE asset_ticker = $2), $3, $1, $2 ON CONFLICT (base_id, quote_id) DO UPDATE SET exchanges = $3, base = $1, quote = $2", [base, quote, pair_details])
    .catch(e => {
      logger.logError("checkPair query", e);
    });
}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:9,代碼來源:database.ts

示例9:

app.post('/event-types', (req, res) => {
	pool.connect((connectionError, client, releaseClient) => {
		if (connectionError) return console.error('Error fetching client from pool', connectionError);

		client.query(`SELECT event_type.id as key, event_type.title as value, event_type.body FROM event_type WHERE event_type.title LIKE '%${req.body.query}%';`, (queryError, result) => {
			if (queryError) return console.error('Error querying database', queryError);

			res.send(result.rows);
			releaseClient();
		});
	});
});
開發者ID:Chronovis,項目名稱:timeline-server,代碼行數:12,代碼來源:index.ts


注:本文中的pg.Pool類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。