Loopback 4如何获取扩展中的数据计数

问题描述 投票:0回答:1

我有关于扩展名的数据

http://[::1]:3000/carts?filter[where][user_id]=5

现在,我想获取数据计数,即该URL上的记录数。如何实现这一目标。我没有找到任何过滤器或方法。预先谢谢你

loopbackjs loopback4
1个回答
0
投票

我刚刚添加了新的扩展程序来解决此问题。

    @get('/users/{id}/carts/count', {
    responses: {
      '200': {
        description: 'Users model count',
        content: { 'application/json': { schema: CountSchema } },
      },
    },
  })
  async count(
    @param.query.object('where', getWhereSchemaFor(Users)) where?: Where<Users>,
  ): Promise<Count> {
    return this.usersRepository.count(where);
  }

现在,我可以依靠url'users / id / carts / count']了>

© www.soinside.com 2019 - 2024. All rights reserved.