当前位置: 首页>>代码示例>>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;未经允许,请勿转载。