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 implements CreateProcess
{ {
public data; public data;
public result;
async process(): Promise<any> { async process(): Promise<any> {
this.result = await this.getDelegate().create({ this.result = await this.getDelegate().create({
data: this.data, data: this.data,
}); });
} }
output() {
this.result;
}
} }

View File

@ -6,15 +6,10 @@ export class PrismaDeleteProcess
implements DeleteProcess implements DeleteProcess
{ {
public id: any; public id: any;
private result: any;
async process(): Promise<any> { async process(): Promise<any> {
this.result = await this.getDelegate().delete({ this.result = await this.getDelegate().delete({
where: { id: this.id }, 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'; import { PrismaProcess } from './prisma.process';
export class PrismaListProcess extends PrismaProcess implements ListProcess { export class PrismaListProcess extends PrismaProcess implements ListProcess {
private result;
async process(): Promise<any> { async process(): Promise<any> {
this.result = await this.getDelegate().findMany(); this.result = await this.getDelegate().findMany();
} }
output() {
return this.result;
}
} }

View File

@ -6,7 +6,6 @@ export class PrismaPaginationProcess
implements PaginationProcess implements PaginationProcess
{ {
public params: { page: number; limit: number }; public params: { page: number; limit: number };
private result;
async process(): Promise<any> { async process(): Promise<any> {
const { page, limit } = this.params; const { page, limit } = this.params;
@ -18,8 +17,4 @@ export class PrismaPaginationProcess
take: parseInt(limit.toString(), 10), 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 { export class PrismaReadProcess extends PrismaProcess implements ReadProcess {
public id; public id;
private result;
async process(): Promise<any> { async process(): Promise<any> {
this.result = await this.getDelegate().findUnique({ this.result = await this.getDelegate().findUnique({
where: { id: this.id }, where: { id: this.id },
}); });
} }
output() {
return this.result;
}
} }

View File

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

View File

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