-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodule.service.ts
29 lines (24 loc) · 974 Bytes
/
module.service.ts
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
import { Injectable } from "@nestjs/common";
import { LoggerService } from '../common/service/logger.service';
import { InjectModel } from "@nestjs/mongoose";
import { Model, Types } from "mongoose";
import { Modules } from "./schemas/modules.schema";
import { v4 as uuid } from 'uuid';
@Injectable()
export class ModulesService {
constructor(
@InjectModel(Modules.name) private readonly appModel: Model<Modules>,
private readonly logger: LoggerService
) { }
async create(product: any): Promise<any> {
const id: string = uuid();
this.logger.log('modules service create called', id, 'modules.service.ts', '', '', 'create-service');
const createProduct = await this.appModel.create(product);
return createProduct;
}
async findAll(): Promise<any[]> {
const id: string = uuid();
this.logger.log('modules service findall called', id, 'modules.service.ts', '', '', 'findAll-service');
return this.appModel.find().exec();
}
}