當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript objection.Model類代碼示例

本文整理匯總了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;未經允許,請勿轉載。