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


TypeScript bookshelf类代码示例

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


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

示例1: Knex

/// <reference path="bookshelf.d.ts" />
/// <reference path="../knex/knex.d.ts" />

import * as Knex from 'knex';
import * as Bookshelf from 'bookshelf';

var knex = Knex({
	client: 'sqlite3',
	connection: {
		filename: ':memory:',
	},
});

// Examples

var bookshelf = Bookshelf(knex);

class User extends bookshelf.Model<User> {
	get tableName() { return 'users'; }
	messages() : Bookshelf.Collection<Posts> {
		return this.hasMany(Posts);
	}
}

class Posts extends bookshelf.Model<Posts> {
	get tableName() { return 'messages'; }
	tags() : Bookshelf.Collection<Tag> {
		return this.belongsToMany(Tag);
	}
}
开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:30,代码来源:bookshelf-tests.ts

示例2: knex

import * as knex from "knex";
import {database as knexConnection} from "../knex/knexfile"
import * as bookshelf from "bookshelf"

let dbConnection = knex(knexConnection);
let db = bookshelf(dbConnection);

db.plugin('registry');

export {db};
开发者ID:waffle-iron,项目名称:CRM,代码行数:10,代码来源:db.ts

示例3: require

import * as bookshelf from "bookshelf";
import * as knex from "knex";
import * as pg from "pg";

pg.defaults.ssl = true;

// Fix for parsing of numeric fields
pg.types.setTypeParser(1700, "text", parseFloat);

import knexfile = require("./knexfile");

const dbConfig = knexfile[process.env.NODE_ENV];

export = bookshelf(knex(dbConfig));
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:14,代码来源:bookshelf.ts

示例4: bookshelf

ďťżimport {knex} from "./knex";
import * as bookshelf from "bookshelf";
export var db = bookshelf(knex);
开发者ID:DominicBisset,项目名称:BigLeagueServer,代码行数:3,代码来源:bookshelf.ts

示例5: constructor

    constructor(dataBaseInfo: IConnection) {
        // PostgreSQL, MySQL, and SQLite3.
        
        
        // XXX::: Dont know about port
        let knex = Knex({
            client: dataBaseInfo.driver,
            connection: {
                host: dataBaseInfo.host,
                user: dataBaseInfo.username,
                password: dataBaseInfo.password,
                database: dataBaseInfo.database,
                charset: 'utf8'
            }
        });

        knex['_config'] = dataBaseInfo;
        // XXX::: todo for mongo
        // XXX::: todo for elastic
        
        this._connection = Bookshelf(knex);
    }
开发者ID:yogendrap,项目名称:PlZoo,代码行数:22,代码来源:Connection.ts


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