All files / src/repositories company-party.repository.ts

100% Statements 17/17
100% Branches 0/0
100% Functions 1/1
100% Lines 15/15

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 381x 1x 1x 1x 1x   1x                       37x   37x   37x   37x   37x     37x 37x     37x 37x      
import { Getter, inject } from '@loopback/core';
import { BelongsToAccessor, HasOneRepositoryFactory, repository } from '@loopback/repository';
import { BaseCrudRepository, CompanyPersonaRepository, CompanyRepository, UserRepository } from '.';
import { LogChainDataSource } from '../datasources';
import { Company, CompanyParty, CompanyPartyRelations, CompanyPersona, User } from '../models';
 
export class CompanyPartyRepository extends BaseCrudRepository<
  CompanyParty,
  typeof CompanyParty.prototype.id,
  CompanyPartyRelations
> {
  public readonly creator: BelongsToAccessor<User, typeof User.prototype.id>;
  public readonly modifier: BelongsToAccessor<User, typeof User.prototype.id>;
  public readonly company: HasOneRepositoryFactory<Company, typeof Company.prototype.id>;
  public readonly company_persona: HasOneRepositoryFactory<CompanyPersona, typeof CompanyPersona.prototype.id>;
  constructor(
    @inject('datasources.logchain') dataSource: LogChainDataSource,
    @repository.getter('UserRepository')
    protected userRepoGetter: Getter<UserRepository>,
    @repository.getter('CompanyRepository')
    protected companyRepoGetter: Getter<CompanyRepository>,
    @repository.getter('CompanyPersonaRepository')
    protected companyPersonaRepoGetter: Getter<CompanyPersonaRepository>,
  ) {
    super(CompanyParty, dataSource);
    // register creator relation
    this.creator = this.createBelongsToAccessor('creator', userRepoGetter);
 
    // register company relation
    this.company = this.createHasOneRepositoryFactoryFor('company', companyRepoGetter);
    this.registerInclusionResolver('company', this.company.inclusionResolver);
 
    // register party relation
    this.company_persona = this.createHasOneRepositoryFactoryFor('company_persona', companyPersonaRepoGetter);
    this.registerInclusionResolver('company_persona', this.company_persona.inclusionResolver);
  }
}