且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 NestJs 从数据库中获取隐藏字段

更新时间:2023-02-08 18:01:33

根据文档可以选择隐藏值

According to the documentation you can select hidden value by using

.addSelect('user.password')

您有 .addSelect('password', 'password') 这将不起作用.不要为隐藏列的列设置别名.(可能是 TypeOrm 中的一个错误).

You have .addSelect('password', 'password') which will not work. Do not alias the columns for hidden columns. (Probably a bug in TypeOrm).

这也行

   .select('user.password')

对于相同的列,您不需要 selectaddSelectaddSelect 什么都不做,因为已经选择了这些列.

You don't need both select and addSelect for the same columns, the addSelect does nothing since the columns are already selected.