问题描述
我有以下需求,需要关闭/打开“字段”过滤器中的某些字段,但是我不知道如何与称为Employee的模型进行交互。
我知道我需要对Employee模型进行一个FOR循环,但是我不知道如何访问模型中的数据
请问有人在那里吗?谢谢3000!
export class Employee extends Entity {
@property({
type: 'string',id: true,generated: false,required: true,})
id: string;
@property({
type: 'string',required: false,default: null,})
prefix: string;
@property({
type: 'string',})
firstName: string;
@property({
type: 'string',})
middleName: string;
@property({
type: 'string',})
lastName: string;
constructor(data?: Partial<Employee>) {
super(data);
}
}
export interface EmployeeRelations {
// describe navigational properties here
}
export type EmployeeWithRelations = Employee & EmployeeRelations;
解决方法
要从结果中排除属性,只需在“字段”过滤器中将其设置为false
,如下所示:
/users?filter={"fields":{"password":false}}
这是文档中的一个示例:https://loopback.io/doc/en/lb4/Fields-filter.html