本文整理汇总了TypeScript中pg-promise.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript pg-promise.default方法的具体用法?TypeScript pg-promise.default怎么用?TypeScript pg-promise.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pg-promise
的用法示例。
在下文中一共展示了pg-promise.default方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: pgPromise
/// <reference path='../../typescript/pg-promise' />
import * as pgPromise from 'pg-promise';
import * as pgSubset from 'pg-subset';
var pgp:pgPromise.IMain = pgPromise();
var pg = pgp.pg;
var client = new pg.Client({});
var query = new pg.Query();
var connection = new pg.Connection();
var database = pg.defaults.database;
var col:pgSubset.IColumn;
var res:pgSubset.IResult;
示例2: lib
/// <reference path="../pg-promise.d.ts" />
//
// To run: tsc basic.ts --target es6 --module commonjs
import * as lib from "pg-promise";
var pgp = lib({
capSQL: true
});
pgp.pg.defaults.poolSize = 20;
var sql = pgp.minify('test--query');
var db = pgp('connection');
db.task(t=> {
return t.batch([
t.one('query'),
t.none('query')
]);
})
.then(data=> {
})
.catch(error=> {
});
示例3: pgPromise
import * as pgPromise from 'pg-promise';
const pgp = pgPromise({});
const dbase = pgp('postgres://ivan:123456@localhost:5432/blog');
export default dbase;
示例4: pgPromise
/// <reference path='../../typescript/pg-promise' />
import * as pgPromise from 'pg-promise';
var pgp = pgPromise({
capSQL: true
});
var col1 = new pgp.helpers.Column({
name: 'third-col',
prop: 'third',
def: 888,
cast: '',
cnd: true,
init: (value)=> {
return this.test;
},
skip: ()=> {
return false;
}
});
var col2 = new pgp.helpers.Column('col');
var data = [
{
first: 1,
second: 'two'
}, {
first: 111,
second: 'hello'
示例5: pgPromise
/// <reference path='../../typescript/pg-promise' />
import * as pgPromise from 'pg-promise';
var pgp:pgPromise.IMain = pgPromise({
connect: (bla1:any, dc:any, fresh:boolean)=> {
},
receive: (data:any, result:any, e:any)=> {
var dc = e.dc;
var d = data[0].prop;
var r = result.fields[0].name;
var query = e.query;
},
query: (e:any)=> {
var dc = e.dc;
var query = e.query;
},
error: (err:any, e:any)=> {
var dc = e.dc;
var query = e.query;
},
extend: (obj:any, dc:any)=> {
obj['method'] = (val:any)=> {
return obj.one(null, val);
}
}
});
var db = pgp('connection');
db.task(t=> {
示例6: sql
import got = require('got');
import parse = require('csv-parse');
import highland = require('highland');
import * as pgPromise from 'pg-promise';
var pgp = pgPromise();
var db = pgp({
host: '127.0.0.1',
port: 5432,
database: 'uber',
user: 'uber',
password: 'moo'
});
// Helper for linking to external query files:
function sql(file) {
return new pgp.QueryFile(file, {minify: true});
}
var sql_drop = sql('./sql/drop.sql');
var sql_create = sql('./sql/create.sql');
function reset_database():Promise<void> {
return db.tx(function (t) {
return t.batch([
t.none(sql_drop),
t.none(sql_create)
]);
});
}
示例7: initialize
import * as pgp from "pg-promise"
import * as monitor from "pg-monitor"
import * as Promise from "bluebird"
import * as range from "pg-range"
const options = {
promiseLib: Promise
};
monitor.attach(options);
const pgpInstance = pgp(options);
range.install(pgpInstance.pg);
var client : pgp.IDatabase<any> = null;
export function initialize(connectionString: string) {
client = pgpInstance(connectionString);
}
export function getClient() {
return client;
}
示例8: create
/// <reference path='../../typescript/pg-promise' />
import * as pgPromise from 'pg-promise';
function create(cb:any) {
return {};
}
var adapter = new pgPromise.PromiseAdapter(create, (data)=> {
}, (error)=> {
});
var pgp = pgPromise({
promiseLib: adapter
});
示例9: pgPromise
/// <reference path='../../typescript/pg-promise' />
import * as pgPromise from 'pg-promise';
var pgp = pgPromise({
receive: (data, result, e)=> {
var dc = e.dc;
var d = data[0].prop;
var r = result.fields[0].name;
var query = e.query;
},
query: (e)=> {
var dc = e.dc;
var query = e.query;
},
error: (err, e)=> {
var dc = e.dc;
var query = e.query;
},
extend: (obj, dc)=> {
obj['method'] = (val)=> {
return obj.one(null, val);
}
}
});
var db = pgp('connection');
db.task(t=> {
var dc = t.ctx.dc;
return t.batch([
示例10: configureDatabase
export function configureDatabase() {
db = pgp()(process.env.DATABASE_URL);
}