@smallprod/models
Version:
42 lines (33 loc) • 806 B
text/typescript
import { Entity, Field, OneToMany, Table } from '../../..';
import ArticleEntity from './article.entity';
('categories')
export default class CategoryEntity extends Entity {
({
type: 'bigint',
autoIncrement: true,
id: true,
name: 'id',
primary: true,
})
private id = 0;
({
type: {
type: 'varchar',
length: 50,
},
unique: true,
})
private label: string;
('articles', false)
private articles: ArticleEntity[] = [];
public constructor(label: string) {
super();
this.label = label;
}
public fetchArticles = async () => {
return await this.fetch('articles');
};
public getId = () => this.id;
public getLabel = () => this.label;
public setLabel = (label: string) => (this.label = label);
}