mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-21 19:06:21 +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
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user