當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。