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 simple DB layer

This commit is contained in:
Fedor Katurov 2021-05-04 11:38:22 +07:00
parent f3a746efe8
commit c0588acd26
15 changed files with 476 additions and 11 deletions

View file

@ -0,0 +1,47 @@
import { Storage } from "../index";
import { VkEvent } from "../../vk/types";
import { Event } from "../types";
import { PostgresConfig } from "./types";
import { Connection, createConnection } from "typeorm";
export class PostgresDB implements Storage {
private connection: Connection;
constructor(private config: PostgresConfig) {}
connect = async () => {
this.connection = await createConnection({
type: "postgres",
url: this.config.uri,
});
};
getEvent = async (
type: VkEvent,
id: number,
groupId: number,
channel: string
) => {
return {
type,
id,
groupId,
channel,
tgMessageId: 0,
createdAt: new Date(),
updatedAt: new Date(),
};
};
createEvent = async (event: Event) => event;
getLikesFor = async (channel: string, messageId: number) => [];
getLikeBy = async (channel: string, messageId: number, author: number) => ({
channel,
messageId,
author,
text: "",
createdAt: new Date(),
updatedAt: new Date(),
});
}