mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
24 lines
468 B
TypeScript
24 lines
468 B
TypeScript
/**
|
|
* Models
|
|
*/
|
|
import Category from 'App/Models/Category';
|
|
|
|
export default class CategoryRepository {
|
|
private Category: typeof Category;
|
|
|
|
constructor() {
|
|
this.Category = Category;
|
|
}
|
|
|
|
/**
|
|
* Get category by id
|
|
*
|
|
* @param id Category id
|
|
* @returns Caregory or null
|
|
*/
|
|
public async getById(id: string | number): Promise<Category | null> {
|
|
const category = await this.Category.query().where('id', id).first();
|
|
return category;
|
|
}
|
|
}
|