【发布时间】:2019-12-21 07:47:00
【问题描述】:
我正在通过 get api 获取产品列表。我想在该 get api 中应用搜索 api(我们正在获取产品的完整列表)。那就是我想将 name 参数作为可选参数。如果用户在搜索框中输入名称,那么 api 将按名称搜索该产品并显示它。如果用户不输入名称,那么它将显示产品的完整列表。这是我的 loopback4 代码
@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'}]});
}
【问题讨论】:
标签: loopback4