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:
parent
c5c3c013ba
commit
50db549cbe
5 changed files with 33 additions and 4 deletions
|
@ -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 (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue