UNPKG

@smallprod/models

Version:
72 lines (71 loc) 2.96 kB
"use strict"; 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); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require("../../.."); const category_entity_1 = __importDefault(require("./category.entity")); let ArticleEntity = class ArticleEntity extends __1.Entity { constructor(title, publishedAt, nbPages, category, authors = []) { super(); this.id = 0; this.authors = []; this.category = null; this.getId = () => this.id; this.getCategory = () => this.category; this.getAuthors = () => this.authors; this.setCategory = (category) => (this.category = category); this.setAuthors = (authors) => (this.authors = authors); this.fetchAuthors = (context, dbName) => this.fetch('authors', context, dbName); this.title = title; this.publishedAt = publishedAt; this.nbPages = nbPages; this.category = category; this.authors = authors; } }; __decorate([ __1.Id(), __1.PrimaryKey(), __1.BigInt(), __1.AutoIncrement(), __metadata("design:type", Object) ], ArticleEntity.prototype, "id", void 0); __decorate([ __1.Varchar(50), __metadata("design:type", String) ], ArticleEntity.prototype, "title", void 0); __decorate([ __1.Date(), __1.FieldName('publishedat'), __metadata("design:type", Object) ], ArticleEntity.prototype, "publishedAt", void 0); __decorate([ __1.Int(), __1.Check('> 0'), __1.Default('10'), __1.FieldName('nbpages'), __metadata("design:type", Number) ], ArticleEntity.prototype, "nbPages", void 0); __decorate([ __1.ManyToMany('users', 'article_authors', false), __metadata("design:type", Array) ], ArticleEntity.prototype, "authors", void 0); __decorate([ __1.ManyToOne('categories', true), __metadata("design:type", Object) ], ArticleEntity.prototype, "category", void 0); ArticleEntity = __decorate([ __1.Table('articles'), __metadata("design:paramtypes", [String, Object, Number, category_entity_1.default, Array]) ], ArticleEntity); exports.default = ArticleEntity;