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


TypeScript Pool.end方法代碼示例

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


在下文中一共展示了Pool.end方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: done

  password: 'secret', //env var: PGPASSWORD
  port: 5432, //env var: PGPORT
  max: 10, // max number of clients in the pool
  idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed
  Promise,
};
var pool = new pg.Pool(config);

pool.connect((err, client, done) => {
  if(err) {
    return console.error('error fetching client from pool', err);
  }
  client.query('SELECT $1::int AS number', ['1'], (err, result) => {
    done();

    if(err) {
      return console.error('error running query', err);
    }
    console.log(result.rows[0].number);
  });
});

pool.on('error', (err, client) => {
  console.error('idle client error', err.message, err.stack)
})

pool.end();
pool.end(() => {
    console.log("pool is closed");
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:pg-tests.ts

示例4: NOW

  if (err) {
    console.error('Error executing query', err.stack);
    return;
  }
  console.log(result.rows[0].name);
});

pool.query('SELECT $1::text as name', ['brianc'])
  .then((res) => console.log(res.rows[0].name))
  .catch(err => console.error('Error executing query', err.stack));
pool.query({ text: 'SELECT $1::text as name' }, ['brianc'])
  .then((res) => console.log(res.rows[0].name))
  .catch(err => console.error('Error executing query', err.stack));

pool.end(() => {
  console.log('pool has ended');
});

pool.end().then(() => console.log('pool has ended'));

(async () => {
  const client = await pool.connect();
  await client.query('SELECT NOW()');
  client.release();
})();

// client constructor tests
// client config object tested above
let c = new Client(); // empty constructor allowed
c = new Client('connectionString'); // connection string allowed
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:pg-tests.ts

示例5: QueryStream

import * as QueryStream from 'pg-query-stream';
import * as pg from 'pg';

const options: QueryStream.Options = {
    highWaterMark: 1000,
    batchSize: 100
};

const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000], options);

const pool = new pg.Pool();
pool.connect((err, client, done) => {
    const stream = client.query(query);
    stream.on('end', () => {
        client.end();
    });
    stream.on('data', (data: any) => {
        console.log(data);
    });
});
pool.end();
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:21,代碼來源:pg-query-stream-tests.ts

示例6: shutdown

export function shutdown(): Promise < any > {
  return pool.end();
}
開發者ID:bradbesserman,項目名稱:Crypto-Price-API,代碼行數:3,代碼來源:database.ts


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