@smallprod/models
Version:
49 lines (40 loc) • 860 B
text/typescript
import {
AutoCreateNUpdate,
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);
}