-
-
Save imflamboyant/2e0376bcc977439a83de8ba9245024f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@nestjs/common'; | |
| import { InjectRepository } from '@nestjs/typeorm'; | |
| import { Repository } from 'typeorm'; | |
| import { Song } from './entities/song.entity'; | |
| @Injectable() | |
| export class SongService { | |
| constructor( | |
| @InjectRepository(Song) private songRepository: Repository<Song>, | |
| ) { | |
| } | |
| async create(song: Song): Promise<Song> { | |
| return await this.songRepository.save(song); | |
| } | |
| async findAll(): Promise<Song[]> { | |
| return await this.songRepository.find(); | |
| } | |
| async findOne(id: number): Promise<Song> { | |
| return await this.songRepository.findOne({ id }); | |
| } | |
| async remove(id: number): Promise<void> { | |
| await this.songRepository.delete(id); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment