import { injectable } from 'inversify' ; import 'reflect-metadata' ; import { CarModel } from './car.model' ; import * as _ from 'lodash' ; @ injectable ( ) export class CarsService { private carsList : CarModel [ ] = [ { id : '1' , name : 'Car 1' , description : 'Description Car 1' , version : '1.0.0' , author : { id : '1' , name : [ 'John DOE' ] , } , } as unknown as CarModel , { id : '2' , name : 'Car 2' , description : 'Description Car 2' , version : '2.0.0' , author : { id : '1' , name : [ 'John DOE' ] , } , } as unknown as CarModel , ] ; public getCars ( ) { return this . carsList ; } public getCarsByIds ( ids ) { return this . carsList . filter ( car => ids . includes ( car . id ) ) ; } public addCar ( car ) { this . carsList . push ( car ) ; return car ; } public getCarById ( id ) { return _ . find ( this . carsList , ( car ) => { return _ . isEqual ( car . id , id ) ; } ) ; } }