UNPKG

cc-core-cli

Version:

Command Line Interface tool for generating project templates for the (Your Platform's Name) platform.

31 lines (26 loc) 1.08 kB
import * as mongoose from "mongoose"; import * as _ from "lodash"; import * as moduleConfig from "../module.json"; import { Injectable, Inject, Scope } from "@nestjs/common"; import { InjectModel } from "@nestjs/mongoose"; import { EntitiesService, BaseService } from "@shopstack/cc-core-lib/core"; import { ClsService } from "nestjs-cls"; import { Example, ExampleSchema } from "./example.schema"; import { ExampleLayout } from "./example.layout"; const { code, name } = moduleConfig; @Injectable() export class DemoExampleService extends BaseService<Example> { constructor( readonly cls: ClsService, private entitiesService: EntitiesService, @InjectModel(`${code}_${_.snakeCase(Example.name)}`) protected model: mongoose.Model<Example> ) { super(cls, model); } public async init(): Promise<string> { DemoExampleService.prefix = code; await this.entitiesService.refreshSystemSchema(DemoExampleService, this.model, Example, ExampleSchema, { layouts: ExampleLayout }); return `[${_.toUpper(name)} MODULE] ${_.snakeCase(Example.name)}`; } }