本文整理汇总了TypeScript中objection.Model类的典型用法代码示例。如果您正苦于以下问题:TypeScript Model类的具体用法?TypeScript Model怎么用?TypeScript Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: beforeAll
beforeAll(() => {
dotenv.config();
knx = knex({
client: "pg",
connection: `${process.env.DATABASE_URL}_test`,
});
Model.knex(knx);
});
开发者ID:zaeleus,项目名称:lp-api,代码行数:10,代码来源:setupTests.ts
示例2: config
private config(): void {
// Sets the global header `Server` as a middleware. We
// are intentionally receiving and ignoring the `req`
// parameter, indicated by the underscore.
this.app.use((_, res, next): void => {
res.set("Server", "TypeScript-rest");
next();
});
// Initiatlize connection to the database and connect
// the knex query builder to our objection models.
const knex = Knex(Knexfile);
Model.knex(knex);
}
开发者ID:TechEmpower,项目名称:FrameworkBenchmarks,代码行数:15,代码来源:server.ts
示例3: test
test('should add a new record on #save()', async function (t) {
// startup...
const knex = Knex({ client: 'sqlite3', connection: { filename: ':memory:' } });
Model.knex(knex);
Models.One.app = 'myBlog';
const m = new Migration({ tables: [] }, { tables: [Models.One.toJSON()] });
Migration.run(knex, await m.up());
const one = new Models.One({ myBoolean: 1, myDate: Date.now(), myDateTime: Date.now() });
await one.save();
const found = await Models.One.query().where('id', 1);
// teardown...
await knex.destroy();
t.same(one, found[0]);
})
开发者ID:gitter-badger,项目名称:overland,代码行数:18,代码来源:model.ts
示例4: function
return function (target) {
objection.Model.extend(target);
};
开发者ID:bsawyer,项目名称:parka,代码行数:4,代码来源:model.ts
示例5: require
import * as knex from 'knex';
import { Model } from 'objection';
const config = require('../../../../../db/config');
Model.knex(knex(config[process.env.NODE_ENV || 'development']));
开发者ID:rosendi,项目名称:figure,代码行数:7,代码来源:objection.ts
示例6: knex
import knex from "knex";
import { Model } from "objection";
import appConfig from "../../../../app-config";
export const pg = knex({
client: "pg",
version: "9.6",
connection: {
host: appConfig.databaseHost,
database: appConfig.databaseName,
user: appConfig.databaseUser,
password: appConfig.databasePassword,
},
});
Model.knex(pg);
export { UserModel } from "./user";
export { ShapeModel } from "./shape";
export { DocumentModel } from "./document";
开发者ID:carlospaelinck,项目名称:publications-js,代码行数:20,代码来源:index.ts
示例7: knex
import knex from "knex";
import morgan from "morgan";
import { Model } from "objection";
import schema from "./schema";
dotenv.config();
const PORT = process.env.PORT || 3000;
const knx = knex({
client: "pg",
connection: process.env.DATABASE_URL,
});
Model.knex(knx);
const graphqlOptions: ExpressGraphQLOptionsFunction = (request) => ({
context: { request, knex },
schema,
});
const app = express();
app.use(morgan("dev"));
app.use("/graphql", bodyParser.json(), graphqlExpress(graphqlOptions));
app.use(express.static("public"));
// tslint:disable-next-line:no-console
app.listen(PORT, () => console.log(`Listening on :${PORT}`));
开发者ID:zaeleus,项目名称:lp-api,代码行数:31,代码来源:index.ts
示例8: Knex
const configInit = (knexConfig) => {
knex = Knex(knexConfig);
Model.knex(knex);
return Promise.resolve(Model);
};
开发者ID:MarcDeletang,项目名称:bedrock,代码行数:5,代码来源:PostgresWrapper.ts
注:本文中的objection.Model类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论