configureDB.ts
822 Bytes
import { Application } from "express";
import { ConnectionOptions, createConnection } from "typeorm";
import Contract from "entity/Contract";
import Drone from "entity/Drone";
import Model from "entity/Model";
import Org from "entity/Org";
import User from "entity/User";
import Dataset from "entity/Dataset";
import fake from "../fake";
const options: ConnectionOptions = {
type: "oracle",
host: "localhost",
port: 1521,
username: "system",
password: "oracle",
database: "khu",
logger: "debug",
synchronize: true,
entities: [Contract, Drone, Model, Org, User, Dataset]
};
export default async (app: Application) => {
try {
const connection = await createConnection(options);
await fake(connection);
Object.assign(app.locals, { connection });
} catch (e) {
console.log(e);
}
};