I am getting list of products through a get api. I want to apply search api in that get api(in which we are fetching full list of product). that is i want to give name parameter as optional. If user enters name in search box then api will search that product by name and show it. If user don't enter the name then it will display full list of product. here is my loopback4 code
@get('/zones', {
responses: {
'200': {
description: 'Array of Zone model instances',
content: {
'application/json': {
schema: {
type: 'array',
items: getModelSchemaRef(Zone, {includeRelations: true}),
},
},
},
},
},
})
async find(
//@param.path.string('name') name: String,
@param.query.object('filter', getFilterSchemaFor(Zone)) filter?:
Filter<Zone>,
): Promise<Zone[]> {
return this.zoneRepository.find({include: [{relation: 'cameras'}]});
}