@smallprod/models
Version:
56 lines (55 loc) • 2.04 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("../../..");
let CategoryEntity = class CategoryEntity extends __1.Entity {
constructor(label) {
super();
this.id = 0;
this.articles = [];
this.fetchArticles = async () => {
return await this.fetch('articles');
};
this.getId = () => this.id;
this.getLabel = () => this.label;
this.setLabel = (label) => (this.label = label);
this.label = label;
}
};
__decorate([
__1.Field({
type: 'bigint',
autoIncrement: true,
id: true,
name: 'id',
primary: true,
}),
__metadata("design:type", Object)
], CategoryEntity.prototype, "id", void 0);
__decorate([
__1.Field({
type: {
type: 'varchar',
length: 50,
},
unique: true,
}),
__metadata("design:type", String)
], CategoryEntity.prototype, "label", void 0);
__decorate([
__1.OneToMany('articles', false),
__metadata("design:type", Array)
], CategoryEntity.prototype, "articles", void 0);
CategoryEntity = __decorate([
__1.Table('categories'),
__metadata("design:paramtypes", [String])
], CategoryEntity);
exports.default = CategoryEntity;