For example, this is book.service.ts
import { Injectable } from "@nestjs/common";
import { Book } from '../interfaces/book.interface'
@Injectable()
export class BooksService {
private readonly books: Book[] = [];
private create(book: Book) {
console.log(book)
this.books.push(book);
}
private findAll(): Book[] {
return this.books;
}
}
Another buy.service.ts
import { Injectable } from "@nestjs/common";
import { Book } from '../interfaces/book.interface'
@Injectable()
export class BuyService {
private readonly books: Book[] = [];
private findAll(): Book[] {
return this.books;
}
}
The private findAll() methods are the same in the two files. How to create a common logic for them?