import { Injectable } from '@nestjs/common' ; import { Repository } from 'typeorm' ; import { InjectRepository } from '@nestjs/typeorm' ; import { Article } from './article.entity' ; @ Injectable ( ) export class ArticleService { constructor ( @ InjectRepository ( Article ) private readonly articleRepository ) { } async findAllArticles ( ) { return await this . articleRepository . find ( ) ; } async findArticleById ( id ) { return await this . articleRepository . findOne ( id ) ; } async createArticle ( title , slug , content ) { const article = new Article ( ) ; article . title = title ; article . slug = slug ; article . content = content ; return await this . articleRepository . save ( article ) ; } }