import { Pool } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
const pool = new Pool({
database: Deno.env.get("POSTGRES_DATABASE"),
hostname: Deno.env.get("POSTGRES_HOST"),
port: 5432,
user: Deno.env.get("POSTGRES_USER"),
password: Deno.env.get("POSTGRES_PASSWORD"),
connection: {
attempts: 10,
},
options: {
}
}, 10);
export { pool };
import { QueryArrayResult } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
import { pool } from "../database/database.ts";
export class ChatMessageRepository {
public static async getChatMessagesByChannelIdAndUserId(channelId: bigint, userId: bigint): Promise<QueryArrayResult<unknown[]>> {
const client = await pool.connect();
const chatMesages = await client.queryArray(
`SELECT "Content", "IsBot" FROM public."ChatMessages" WHERE "ChannelId" = ${channelId} AND "UserId" = ${userId} ORDER BY "CreatedAt" ASC;`,
);
client.release();
return chatMesages;
}
}
import { Pool } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
const pool = new Pool({
database: Deno.env.get("POSTGRES_DATABASE"),
hostname: Deno.env.get("POSTGRES_HOST"),
port: 5432,
user: Deno.env.get("POSTGRES_USER"),
password: Deno.env.get("POSTGRES_PASSWORD"),
connection: {
attempts: 10,
},
options: {
}
}, 10);
export { pool };
import { QueryArrayResult } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
import { pool } from "../database/database.ts";
export class ChatMessageRepository {
public static async getChatMessagesByChannelIdAndUserId(channelId: bigint, userId: bigint): Promise<QueryArrayResult<unknown[]>> {
const client = await pool.connect();
const chatMesages = await client.queryArray(
`SELECT "Content", "IsBot" FROM public."ChatMessages" WHERE "ChannelId" = ${channelId} AND "UserId" = ${userId} ORDER BY "CreatedAt" ASC;`,
);
client.release();
return chatMesages;
}
}