feat: simplify the result process

This commit is contained in:
Supan Adit Pratama 2024-11-01 16:15:10 +07:00
parent 759a6c7848
commit aa6a655984
7 changed files with 4 additions and 33 deletions

View File

@ -6,15 +6,10 @@ export class PrismaCreateProcess
implements CreateProcess
{
public data;
public result;
async process(): Promise<any> {
this.result = await this.getDelegate().create({
data: this.data,
});
}
output() {
this.result;
}
}

View File

@ -6,15 +6,10 @@ export class PrismaDeleteProcess
implements DeleteProcess
{
public id: any;
private result: any;
async process(): Promise<any> {
this.result = await this.getDelegate().delete({
where: { id: this.id },
});
}
output() {
return this.result;
}
}

View File

@ -2,13 +2,7 @@ import { ListProcess } from '@aditama-labs/nest-autocrud/skeleton';
import { PrismaProcess } from './prisma.process';
export class PrismaListProcess extends PrismaProcess implements ListProcess {
private result;
async process(): Promise<any> {
this.result = await this.getDelegate().findMany();
}
output() {
return this.result;
}
}

View File

@ -6,7 +6,6 @@ export class PrismaPaginationProcess
implements PaginationProcess
{
public params: { page: number; limit: number };
private result;
async process(): Promise<any> {
const { page, limit } = this.params;
@ -18,8 +17,4 @@ export class PrismaPaginationProcess
take: parseInt(limit.toString(), 10),
});
}
output() {
return this.result;
}
}

View File

@ -3,15 +3,10 @@ import { PrismaProcess } from './prisma.process';
export class PrismaReadProcess extends PrismaProcess implements ReadProcess {
public id;
private result;
async process(): Promise<any> {
this.result = await this.getDelegate().findUnique({
where: { id: this.id },
});
}
output() {
return this.result;
}
}

View File

@ -7,7 +7,6 @@ export class PrismaUpdateProcess
{
public id: any;
public data: any;
private result: any;
async process(): Promise<any> {
this.result = await this.getDelegate().update({
@ -15,8 +14,4 @@ export class PrismaUpdateProcess
where: { id: this.id },
});
}
output() {
return this.result;
}
}

View File

@ -1,6 +1,8 @@
import { ISkeletonProcess } from '../interfaces/skeleton-process.interface';
export class DefaultProcess implements ISkeletonProcess {
protected result;
async initialization(): Promise<any> {}
async before(): Promise<any> {}
async begin(): Promise<any> {}
@ -8,7 +10,7 @@ export class DefaultProcess implements ISkeletonProcess {
async end(): Promise<any> {}
async after(): Promise<any> {}
output(): any {
return 'Not Implemented Yet!';
output() {
return this.result;
}
}