当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pg-promise类代码示例

本文整理汇总了TypeScript中pg-promise的典型用法代码示例。如果您正苦于以下问题:TypeScript pg-promise类的具体用法?TypeScript pg-promise怎么用?TypeScript pg-promise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了pg-promise类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: pgPromise

/// <reference path='../../typescript/pg-promise' />

import * as pgPromise from 'pg-promise';

var pgp = 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=> {
开发者ID:ethanbigelow,项目名称:pg-promise,代码行数:31,代码来源:events.ts

示例2: 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'
开发者ID:TimBeyer,项目名称:pg-promise,代码行数:31,代码来源:help.ts

示例3: pgPromise

/// <reference path='../../typescript/pg-promise' />

import * as pgPromise from 'pg-promise';

var value1 = pgPromise.as.array([]);
var value2 = pgPromise.as.array(()=>[]);

var pgp:pgPromise.IMain = pgPromise();

var value3 = pgp.as.array([]);
var value4 = pgp.as.array(()=>[]);
var value5 = pgp.as.format('hello', []);
var value6 = pgp.as.format(new pgPromise.QueryFile(''));
开发者ID:andrewharvey,项目名称:pg-promise,代码行数:13,代码来源:formatting.ts

示例4: 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=> {

    });
开发者ID:RyanMcDonald,项目名称:pg-promise,代码行数:27,代码来源:basic.ts

示例5: require

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)
    ]);
  });
}
开发者ID:cyounkins,项目名称:uber-homework,代码行数:31,代码来源:load.ts

示例6: 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;
}
开发者ID:paavohuhtala,项目名称:lodgist,代码行数:23,代码来源:Connection.ts

示例7: 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
});
开发者ID:DinhTiny,项目名称:pg-promise,代码行数:15,代码来源:adapter.ts

示例8: 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([
开发者ID:NGENDAKURIYOLionel,项目名称:pg-promise,代码行数:31,代码来源:events.ts

示例9: pgPromise

import * as pgPromise from 'pg-promise';

const pgp = pgPromise({});

const dbase = pgp('postgres://ivan:123456@localhost:5432/blog');

export default dbase;
开发者ID:1ven,项目名称:node-blog,代码行数:7,代码来源:index.ts

示例10: configureDatabase

export function configureDatabase() {
  db = pgp()(process.env.DATABASE_URL);
}
开发者ID:thomasboyt,项目名称:manygolf,代码行数:3,代码来源:models.ts


注:本文中的pg-promise类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。