mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-21 10:46:22 +00:00
feat: simplify the result process
This commit is contained in:
parent
759a6c7848
commit
aa6a655984
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user