Property.entity.ts
@Column({ select: false })
address: string;
Property.service.ts
allWithLocation = async () => {
const properties = await this.repository
.createQueryBuilder("property")
.select("property")
.addSelect("property.address")
.getMany();
return properties;
};
Is there a way to write the code above like this using type-orm find options?
allWithLocation = async () => {
const properties = await this.repository.find({
addSelect: ["address"]
});
return properties;
};
Looks like you need to use "relations" property of FindOptionsRelations<T>.
Check here: https://orkhan.gitbook.io/typeorm/docs/find-options