If the model you are querying has a column with a select: false
column, you must use the addSelect
function in order to retrieve the information from the column.
Let’s say you have the following entity:
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@Column({ select: false })
password: string
}
Using a standard find
or query, you will not receive the password
property for the model. However, if you do the following:
const users = await dataSource
.getRepository(User)
.createQueryBuilder()
.select("user.id", "id")
.addSelect("user.password")
.getMany()
You will get the property password
in your query.