Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { Injectable, Logger } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model, Types } from 'mongoose'; import { CrmImport, CrmExport } from '../schemas/automation-import.schema'; @Injectable() export class CrmImportExportService { private readonly logger = new Logger(CrmImportExportService.name); constructor( @InjectModel(CrmImport.name) private readonly importModel: Model<CrmImport>, @InjectModel(CrmExport.name) private readonly exportModel: Model<CrmExport>, ) {} async createImport( tenantId: Types.ObjectId, data: Partial<CrmImport>, ): Promise<CrmImport> { return this.importModel.create({ ...data, tenantId }); } async getImport( tenantId: Types.ObjectId, importId: string, ): Promise<CrmImport | null> { return this.importModel .findOne({ tenantId, _id: new Types.ObjectId(importId) }) .exec(); } async createExport( tenantId: Types.ObjectId, data: Partial<CrmExport>, ): Promise<CrmExport> { return this.exportModel.create({ ...data, tenantId }); } async getExport( tenantId: Types.ObjectId, exportId: string, ): Promise<CrmExport | null> { return this.exportModel .findOne({ tenantId, _id: new Types.ObjectId(exportId) }) .exec(); } } |