1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 06:56:40 +07:00

#4 added entities and synchronization to project

This commit is contained in:
Fedor Katurov 2021-05-04 12:12:31 +07:00
parent c5c3c013ba
commit 50db549cbe
5 changed files with 33 additions and 4 deletions

View file

@ -3,6 +3,10 @@ import { VkEvent } from "../../vk/types";
import { StoredEvent } from "../types";
import { PostgresConfig } from "./types";
import { Connection, createConnection } from "typeorm";
import logger from "../../logger";
import path from "path";
const entities = [path.join(__dirname, "./entities/*")];
export class PostgresDB implements Storage {
private connection: Connection;
@ -12,8 +16,14 @@ export class PostgresDB implements Storage {
this.connection = await createConnection({
type: "postgres",
url: this.config.uri,
entities: ["./entities/*.ts"],
entities,
logging: true,
synchronize: true,
});
await this.connection.synchronize();
logger.info(`db connected to ${this.config.uri}`);
};
getEvent = async (