'Where & Count cant be implemented together in Loopback 4

I am implementing an API that can take out all the data where user_id: user_id but it is not working please help me to implement the same.

here is my code of Follow_api controller:

@get('/follow-masters/count/{id}')
  @response(200, {
    description: 'FollowMaster model count',
    content: {'application/json': {schema: CountSchema}},
  })
  async findCount(
    @param.path.string('user_id') user_id: string,
    @param.where(FollowMaster) where?: Where<FollowMaster>,
  ): Promise<Count> {
    return this.followMasterRepository.count();
  }


Solution 1:[1]

Solved using this code:

@get('/follow-masters/count/{user_id}')
  @response(200, {
    description: 'FollowMaster model count',
    content: {'application/json': {
      schema: FollowMaster
    }
  },
  })
  async findCount(
    @param.path.string('user_id') user_id: string,
    @param.where(FollowMaster) where?: Where<FollowMaster>,
  ): Promise<NonVoid> {
    return this.followMasterRepository.find({
      where: {
        user_id: user_id, ...where,
      },
    });
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shesh Narayan Deshmukh