Skip to content

Commit 296fa8d

Browse files
committed
pg-adapter
1 parent a4f924f commit 296fa8d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@adiwajshing/keyed-db": "^0.2.4",
4747
"@hapi/boom": "^10.0.1",
48+
"@prisma/adapter-pg": "^7.2.0",
4849
"@prisma/client": "^7.2.0",
4950
"@whiskeysockets/baileys": "7.0.0-rc.9",
5051
"axios": "^1.13.2",

src/repository/repository.service.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ export class Query<T> {
4343

4444
import { Prisma, PrismaClient, Webhook } from '@prisma/client';
4545
import { WebhookEvents } from '../whatsapp/dto/webhook.dto';
46-
import { BadRequestException, NotFoundException } from '../exceptions';
46+
import {
47+
BadRequestException,
48+
InternalServerErrorException,
49+
NotFoundException,
50+
} from '../exceptions';
4751
import { Logger } from '../config/logger.config';
4852
import { ConfigService, Database } from '../config/env.config';
53+
import { PrismaPg } from '@prisma/adapter-pg';
4954

5055
type CreateLogs = {
5156
context: string;
@@ -56,7 +61,16 @@ type CreateLogs = {
5661

5762
export class Repository extends PrismaClient {
5863
constructor(private readonly configService: ConfigService) {
59-
super();
64+
super({
65+
adapter: new PrismaPg(
66+
{ connectionString: process.env.DATABASE_URL },
67+
{
68+
onConnectionError(err) {
69+
throw new InternalServerErrorException(err);
70+
},
71+
},
72+
),
73+
});
6074
}
6175

6276
private readonly logger = new Logger(this.configService, Repository.name);
@@ -94,7 +108,7 @@ export class Repository extends PrismaClient {
94108
}
95109

96110
const k = `ARRAY['${key}']`;
97-
const v = `to_jsonb(${value}::boolean)`;
111+
const v = `to_jsonb(${value as string}::boolean)`;
98112

99113
await this.$queryRaw(
100114
Prisma.sql`UPDATE "Webhook" SET events = jsonb_set(events, ${Prisma.raw(

0 commit comments

Comments
 (0)