/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
sample/31-graphql-federation-code-first/posts-application/src/posts/posts.service.ts
24 строки
627 B
soudai-s
sample(31): align method naming with its behavior
15 окт 2021, 07:01
15 окт 2021, 07:01
572fcc4
Код
Авторство
О чём код?
import { Injectable } from '@nestjs/common'; import { Post } from './models/post.model'; @Injectable() export class PostsService { private posts: Post[] = [ { authorId: 1, id: 1, title: 'Lorem Ipsum' }, { authorId: 1, id: 2, title: 'Foo' }, { authorId: 2, id: 3, title: 'Bar' }, { authorId: 2, id: 4, title: 'Hello World' }, ]; findAllByAuthorId(authorId: number): Post[] { return this.posts.filter((post) => post.authorId === Number(authorId)); } findOne(postId: number): Post { return this.posts.find((post) => post.id === postId); } findAll(): Post[] { return this.posts; } }