1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | 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;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | const typeorm_1 = require("typeorm");
|
13 | const user_entity_1 = require("./user.entity");
|
14 | let Organization = Organization_1 = class Organization {
|
15 | };
|
16 | __decorate([
|
17 | typeorm_1.PrimaryGeneratedColumn(),
|
18 | __metadata("design:type", Number)
|
19 | ], Organization.prototype, "id", void 0);
|
20 | __decorate([
|
21 | typeorm_1.Column({
|
22 | name: "name",
|
23 | type: "varchar",
|
24 | length: 20,
|
25 | unique: true
|
26 | }),
|
27 | __metadata("design:type", String)
|
28 | ], Organization.prototype, "name", void 0);
|
29 | __decorate([
|
30 | typeorm_1.ManyToMany(type => user_entity_1.User, user => user.organizations, {
|
31 | cascadeInsert: true,
|
32 | cascadeUpdate: true,
|
33 | lazy: false,
|
34 | eager: false
|
35 | }),
|
36 | __metadata("design:type", Array)
|
37 | ], Organization.prototype, "users", void 0);
|
38 | __decorate([
|
39 | typeorm_1.Column({
|
40 | name: "parentId",
|
41 | type: "integer",
|
42 | nullable: true
|
43 | }),
|
44 | __metadata("design:type", Number)
|
45 | ], Organization.prototype, "parentId", void 0);
|
46 | __decorate([
|
47 | typeorm_1.ManyToOne(type => Organization_1, orientation => orientation.children, {
|
48 | cascadeInsert: true,
|
49 | cascadeUpdate: true,
|
50 | cascadeRemove: false,
|
51 | nullable: true,
|
52 | lazy: false,
|
53 | eager: false,
|
54 | onDelete: "CASCADE"
|
55 | }),
|
56 | typeorm_1.JoinColumn({
|
57 | name: "parentId",
|
58 | referencedColumnName: "id"
|
59 | }),
|
60 | __metadata("design:type", Organization)
|
61 | ], Organization.prototype, "parent", void 0);
|
62 | __decorate([
|
63 | typeorm_1.OneToMany(type => Organization_1, orientation => orientation.parent, {
|
64 | cascadeInsert: true,
|
65 | cascadeUpdate: true,
|
66 | lazy: false,
|
67 | eager: false
|
68 | }),
|
69 | __metadata("design:type", Array)
|
70 | ], Organization.prototype, "children", void 0);
|
71 | Organization = Organization_1 = __decorate([
|
72 | typeorm_1.Entity("organization")
|
73 | ], Organization);
|
74 | exports.Organization = Organization;
|
75 | var Organization_1;
|