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

95.24% Statements 20/21
100% Branches 0/0
50% Functions 1/2
94.74% Lines 18/19

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 1231x   1x     1x                                 1x           1x           1x         1x           1x           1x           1x           1x   82x 1x         1x                                     1x               1x               1x       1x                        
import { hasOne, model, property } from '@loopback/repository';
import { Transform } from 'class-transformer';
import { BaseEntity, Country } from '.';
import { Created, GeoPoint, Modified } from '../types';
import { DateUtils } from '../utils/date';
import { TimeZoneTransform } from '@logchain/decorators';
 
@model({
  settings: {
    postgresql: { table: 'company_locations' },
    foreignKeys: {
      fk_company_locations_company_personas_id: {
        name: 'fk_company_locations_company_personas_id',
        entity: 'CompanyPersona',
        entityKey: 'id',
        foreignKey: 'company_persona_id',
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      },
    },
  },
})
export class CompanyLocation extends BaseEntity implements Created, Modified {
  @property({
    type: 'number',
    id: true,
    generated: true,
  })
  id: number;
 
  @property({
    type: 'number',
    required: true,
  })
  company_persona_id: number;
 
  @property({
    type: 'number',
  })
  company_id: number;
 
  @property({
    type: 'string',
    required: true,
  })
  name: string;
 
  @property({
    type: 'string',
    required: true,
  })
  address: string;
 
  @property({
    type: 'number',
    required: true,
  })
  country_id: number;
 
  @property({
    type: 'string',
    required: true,
  })
  google_map_link: string;
 
  @hasOne(() => Country, { keyTo: 'id', keyFrom: 'country_id', name: 'country' })
  country: Country;
 
  @property({
    type: 'string',
  })
  timezone: string;
 
  @property({
    type: 'object',
    postgresql: {
      dataType: 'jsonb',
    },
    jsonSchema: {
      required: ['lat', 'long'],
      properties: {
        lat: {
          type: 'number',
        },
        long: {
          type: 'number',
        },
      },
    },
  })
  coordinates: GeoPoint;
 
  @property({
    type: 'boolean',
    jsonSchema: {
      default: false,
    },
  })
  status: boolean;
 
  company?: string;
 
  constructor(data?: Partial<CompanyLocation>) {
    super(data);
  }
  @TimeZoneTransform()
  created_date?: Date | undefined;
  created_by?: number | undefined;
 
  @TimeZoneTransform()
  modified_date?: Date | undefined;
  modified_by?: number | undefined;
  
  allow_delete?: boolean;
}
 
export interface CompanyLocationRelations {
  // describe navigational properties here
}
 
export type CompanyLocationWithRelations = CompanyLocation &
  CompanyLocationRelations;