Skip to content

Commit

Permalink
Include substrates to reef check surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Markopoulos committed Nov 26, 2024
1 parent 0c5a6bb commit fffe1cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ApiProperty } from '@nestjs/swagger';
import { Site } from '../sites/sites.entity';
import { ReefCheckSite } from '../reef-check-sites/reef-check-sites.entity';
import { ReefCheckOrganism } from '../reef-check-organisms/reef-check-organisms.entity';
import { ReefCheckSubstrate } from '../reef-check-substrates/reef-check-substrates.entity';

@Entity()
export class ReefCheckSurvey {
Expand Down Expand Up @@ -43,6 +44,10 @@ export class ReefCheckSurvey {
@OneToMany(() => ReefCheckOrganism, (organism) => organism.survey)
organisms: ReefCheckOrganism[];

@ApiProperty()
@OneToMany(() => ReefCheckSubstrate, (substrate) => substrate.survey)
substrates: ReefCheckSubstrate[];

@ApiProperty()
@Column({ nullable: true })
date: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export class ReefCheckSurveysService {
async find(reefCheckSiteId: string): Promise<ReefCheckSurvey[]> {
return this.reefCheckSurveyRepository.find({
where: { reefCheckSiteId },
relations: ['organisms'],
relations: ['organisms', 'substrates', 'reefCheckSite'],
});
}

async findOne(id: string): Promise<ReefCheckSurvey> {
const reefCheckSurvey = await this.reefCheckSurveyRepository.findOne({
where: { id },
relations: ['organisms', 'reefCheckSite'],
relations: ['organisms', 'substrates', 'reefCheckSite'],
// Using getAllColumns to include VirtualColumns - they are not included by default
select: getAllColumns(this.reefCheckSurveyRepository),
});
Expand Down

0 comments on commit fffe1cc

Please sign in to comment.