All files / src/models company-document.model.ts

96.55% Statements 28/29
100% Branches 0/0
87.5% Functions 7/8
96.3% Lines 26/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 1501x 1x                                                                                       1x           1x   38x 1x                 1x               1x   38x 1x   38x 1x           1x           1x   38x 1x   38x 1x                 1x                 1x                 1x           1x   38x 1x   38x 1x                              
import {belongsTo, hasMany, model, property} from '@loopback/repository';
import {
  BaseEntity,
  Company,
  CompanyGateGroup,
  Feature,
  Form,
  Module,
  User,
} from '.';
 
@model({
  settings: {
    postgresql: {table: 'company_documents'},
    indexes: {
      company_form_unique: {
        keys: {
          company_id: 1,
          form_id: 1,
        },
        options: {
          unique: true,
        },
      },
    },
    foreignKeys: {
      fk_company_documents_companies_id: {
        name: 'fk_company_documents_companies_id',
        entity: 'Company',
        entityKey: 'id',
        foreignKey: 'company_id',
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      },
      fk_company_documents_forms_id: {
        name: 'fk_company_documents_forms_id',
        entity: 'Form',
        entityKey: 'id',
        foreignKey: 'form_id',
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      },
    },
  },
})
export class CompanyDocument extends BaseEntity {
  @property({
    type: 'number',
    id: true,
    generated: true,
  })
  id: number;
 
  @belongsTo(() => Company, {name: 'company'})
  company_id: number;
 
  @property({
    type: 'string',
    required: true,
    jsonSchema: {
      maxLength: 100,
    },
  })
  name: string;
 
  @property({
    type: 'string',
    jsonSchema: {
      nullable: true,
    },
  })
  description: string;
 
  @belongsTo(() => Feature, {name: 'feature'})
  feature_id: number;
 
  @belongsTo(() => Module, {name: 'module'})
  module_id: number;
 
  @property({
    type: 'boolean',
    required: true,
  })
  status: boolean;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  created_date: Date;
 
  @belongsTo(() => User, {name: 'creator'})
  created_by: number;
 
  @belongsTo(() => Form, {name: 'form'})
  form_id: number;
 
  @property({
    type: 'boolean',
    default: false,
    jsonSchema: {
      nullable: true,
    }
  })
  form_builder: boolean;
 
  @property({
    type: 'object',
    itemType: 'object',
    postgresql: {
      dataType: 'jsonb',
    },
  })
  form_detail: object;
 
  @property({
    type: 'boolean',
    default: false,
    jsonSchema: {
      nullable: true,
    }
  })
  is_published: boolean;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  modified_date: Date;
 
  @belongsTo(() => User, {name: 'modifier'})
  modified_by?: number;
 
  @hasMany(() => CompanyGateGroup, {keyTo: 'company_document_id'})
  company_gate_groups: CompanyGateGroup[];
 
  constructor(data?: Partial<CompanyDocument>) {
    super(data);
  }
}
 
export interface CompanyDocumentRelations {
  // describe navigational properties here
  creator?: User;
  modifier?: User;
}
 
export type CompanyDocumentWithRelations = CompanyDocument &
  CompanyDocumentRelations;