🔄 cleanup: order with 3 key relations, and ckflow now upto speeded
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { eq, type Database } from "@pkg/db";
|
||||
import { paymentInfo } from "@pkg/db/schema";
|
||||
import { Logger } from "@pkg/logger";
|
||||
import type { Result } from "@pkg/result";
|
||||
import {
|
||||
paymentDetailsModel,
|
||||
type PaymentDetails,
|
||||
type PaymentDetailsPayload,
|
||||
} from "./entities";
|
||||
import type { Result } from "@pkg/result";
|
||||
import { paymentDetails } from "@pkg/db/schema";
|
||||
import { Logger } from "@pkg/logger";
|
||||
|
||||
export class PaymentInfoRepository {
|
||||
db: Database;
|
||||
@@ -18,7 +18,7 @@ export class PaymentInfoRepository {
|
||||
data: PaymentDetailsPayload,
|
||||
): Promise<Result<number>> {
|
||||
const out = await this.db
|
||||
.insert(paymentDetails)
|
||||
.insert(paymentInfo)
|
||||
.values({
|
||||
cardNumber: data.cardDetails.cardNumber,
|
||||
cardholderName: data.cardDetails.cardholderName,
|
||||
@@ -29,15 +29,15 @@ export class PaymentInfoRepository {
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.returning({ id: paymentDetails.id })
|
||||
.returning({ id: paymentInfo.id })
|
||||
.execute();
|
||||
return { data: out[0]?.id };
|
||||
}
|
||||
|
||||
async getPaymentInfo(id: number): Promise<Result<PaymentDetails>> {
|
||||
Logger.info(`Getting payment info with id ${id}`);
|
||||
const out = await this.db.query.paymentDetails.findFirst({
|
||||
where: eq(paymentDetails.id, id),
|
||||
const out = await this.db.query.paymentInfo.findFirst({
|
||||
where: eq(paymentInfo.id, id),
|
||||
});
|
||||
const parsed = paymentDetailsModel.safeParse(out);
|
||||
if (parsed.error) {
|
||||
@@ -50,8 +50,8 @@ export class PaymentInfoRepository {
|
||||
async deletePaymentInfo(id: number): Promise<Result<boolean>> {
|
||||
Logger.info(`Deleting payment info with id ${id}`);
|
||||
const out = await this.db
|
||||
.delete(paymentDetails)
|
||||
.where(eq(paymentDetails.id, id))
|
||||
.delete(paymentInfo)
|
||||
.where(eq(paymentInfo.id, id))
|
||||
.execute();
|
||||
Logger.debug(out);
|
||||
return { data: true };
|
||||
|
||||
Reference in New Issue
Block a user