Solution 1:
For one time requests, you can pass on the filter
query object in the get request with fields
options specifying the columns you need.
Example:
To only return the id
, and name
column.
{
"fields": {
"id": true,
"name": true
}
}
fields can also be supplied on server side like this:
yourRepository.find({fields: ['id', 'name']});
Docs: https://loopback.io/doc/en/lb4/Fields-filter.html
Solution 2:
To disable returning the columns in every request, specify
hiddenProperties
in model definition.
Like below:
@model({
settings: {
hiddenProperties: ['password'] //
}
})
class MyUserModel extends Entity {
@property({id: true})
id: number;
@property({type: 'string'})
email: string;
@property({type: 'string'})
password: string;
...
}
Properties specified in hiddenProperties
will never be returned in responses, you can access them in your js/ts code if you need.
Docs: https://loopback.io/doc/en/lb4/Model.html#hidden-properties