import { Injectable } from '@nestjs/common' ; import { CreatePostDto } from "./dto/create-post.dto" ; import { InjectModel } from "@nestjs/sequelize" ; import { Post } from "./posts.model" ; import { FilesService } from "../files/files.service" ; @ Injectable ( ) export class PostsService { constructor ( @ InjectModel ( Post ) private postRepository , private fileService ) { } async create ( dto , image ) { const fileName = await this . fileService . createFile ( image ) ; const post = await this . postRepository . create ( { ... dto , image : fileName } ) ; return post ; } }