@Injectable()
export class WeightPriceService { constructor(readonly dbContext: DbContext) {}
async findPriceByWeight(weight: number, tariffType?: PackageMaterialType): Promise<number> {
const { price } = await this.dbContext.tariffs.findOne({
where: {
type: tariffType ? tariffType : ,
isActive: true,
weight: { min: LessThan(weight), max: MoreThan(weight) },
},
relations: ['weight'],
});
return price;
}
}
Is "tariffType" parameter is true I would like to check "type:tariffType" else do not want to check "type"