import { Get , Post , Put , Delete , Body , Param } from '@nestjs/common' ; import { InMemoryDBService } from '../services' ; import { InMemoryDBEntity } from '../interfaces' ; import { Observable } from 'rxjs' ; example Controller export abstract class InMemoryDBEntityAsyncController < T extends InMemoryDBEntity > { constructor ( protected readonly dbService ) { } @ Post ( ) public create ( @ Body ( ) record ) { if ( Array . isArray ( record ) ) { return this . dbService . createManyAsync ( record ) ; } return this . dbService . createAsync ( record ) ; } @ Put ( ':id' ) public update ( @ Param ( 'id' ) id , @ Body ( ) record ) { return this . dbService . updateAsync ( { id , ... record } as T ) ; } @ Put ( ) public updateMany ( @ Body ( ) records ) { return this . dbService . updateManyAsync ( records ) ; } @ Delete ( ':id' ) public delete ( @ Param ( 'id' ) id ) { return this . dbService . deleteAsync ( id ) ; } @ Delete ( ) public deleteMany ( @ Body ( ) ids ) { return this . dbService . deleteManyAsync ( ids ) ; } @ Get ( ':id' ) public get ( @ Param ( 'id' ) id ) { return this . dbService . getAsync ( id ) ; } @ Get ( ) public getMany ( @ Body ( ) ids ? ) { if ( ids && Array . isArray ( ids ) ) { return this . dbService . getManyAsync ( ids ) ; } return this . dbService . getAllAsync ( ) ; } }