mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-24 21:16:21 +00:00
feat: simple working list process
This commit is contained in:
parent
3755f49181
commit
231fd12dea
@ -1 +1 @@
|
||||
export declare const PRISMA_DELEGATE = 'PRISMA_DELEGATE';
|
||||
export const PRISMA_DELEGATE = 'PRISMA_DELEGATE';
|
||||
|
@ -1,14 +1,8 @@
|
||||
import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PrismaService } from './prisma.service';
|
||||
import { PrismaListProcess } from './processes/list.process';
|
||||
|
||||
@Module({
|
||||
providers: [
|
||||
PrismaService,
|
||||
{ provide: READ_ENTIRE_PROCESS, useClass: PrismaListProcess },
|
||||
,
|
||||
],
|
||||
providers: [PrismaService],
|
||||
exports: [PrismaService],
|
||||
})
|
||||
export class PrismaModule {}
|
||||
|
@ -2,7 +2,7 @@ import { ListProcess } from '@autocrud/skeleton/processes/list.process';
|
||||
import { PrismaProcess } from './prisma.process';
|
||||
|
||||
export class PrismaListProcess extends PrismaProcess implements ListProcess {
|
||||
private data;
|
||||
private data: any;
|
||||
|
||||
async process(): Promise<any> {
|
||||
this.data = await this.getDelegate().findMany();
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { DefaultProcess } from '@autocrud/skeleton/processes/default.process';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { PRISMA_DELEGATE } from '../constants';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaProcess extends DefaultProcess {
|
||||
constructor(
|
||||
@Inject(PRISMA_DELEGATE)
|
||||
private delegate: any,
|
||||
private delegate,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
get getDelegate() {
|
||||
getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
export declare const READ_ENTIRE_PROCESS = 'READ_ENTIRE_PROCESS';
|
||||
export const READ_ENTIRE_PROCESS = 'READ_ENTIRE_PROCESS';
|
||||
|
@ -1,10 +1,13 @@
|
||||
import { PrismaModule, PrismaService } from '@autocrud/prisma';
|
||||
import { PRISMA_DELEGATE } from '@autocrud/prisma/constants';
|
||||
import { ListProcess } from '@autocrud/skeleton/processes/list.process';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { READ_ENTIRE_PROCESS } from '@autocrud/skeleton';
|
||||
import { PrismaListProcess } from '@autocrud/prisma/processes/list.process';
|
||||
|
||||
const delegateFactory = {
|
||||
const customFactory = {
|
||||
provide: PRISMA_DELEGATE,
|
||||
useFactory: (prisma: PrismaService) => {
|
||||
return prisma.user;
|
||||
@ -13,8 +16,13 @@ const delegateFactory = {
|
||||
};
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [AppService, delegateFactory],
|
||||
providers: [
|
||||
AppService,
|
||||
PrismaService,
|
||||
customFactory,
|
||||
{ provide: READ_ENTIRE_PROCESS, useClass: PrismaListProcess },
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
Loading…
Reference in New Issue
Block a user