I'd like to protect certain properties on the data-layer level. For example I'd like to protect the password hash I store in the database for a user, so that it doesn't show up in arbitrary select
-statements.
This way only when it's explicitly requested in a select property, property2
statement.
I think a more accurate answer would be to set select: false
on column options:
@Column({ select: false })
password: string;
And explicitly select the column like this:
const user = await getRepository(User)
.createQueryBuilder()
.addSelect('password')
.getOne()