title: LoopBack4 execute a custom group by with find or use existing methods
body: <p>Hi is use loopback 4 for customs rest</p>
  
  <p>this is my collection when i use console.log of this find <code>const resultfilters = await this.reactionsRepository.find(filter)</code></p>
  
  <pre><code>[ Reactions {
    id: 'c3RyaW5nOnN0cmluZw==',
    websiteId: 'string',
    sectionSlug: 'string',
    contentId: 'string',
    reactionId: 'string',
    bearerToken: undefined },
  
  
     Reactions {
      id: 'string',
      websiteId: 'string',
      sectionSlug: 'string',
      contentId: 'string',
      reactionId: 'string',
      bearerToken: undefined },
    Reactions {
      id: 'string1',
      websiteId: 'string',
      sectionSlug: 'string',
      contentId: 'string',
      reactionId: 'string',
      bearerToken: undefined } ]
  </code></pre>
  
  <p>i want to use group by in custom select for example</p>
  
  <pre><code>const resultfilters = await this.reactionsRepository.find(filter)
  </code></pre>
  
  <p>and this filter use a custom group by and count, this step i dont know how make but something like that</p>
  
  <pre><code>const resultgroup = await this.reactionsRepository.groupby(resultfilters)
  const resultend = await this.reactionsRepository.count(resultgroup)
  </code></pre>
  
  <p>if i can use, how make this with loopback 4?</p>
  
  <p>or in some case i need use the before filter and later apply the filter with my custom group by and count</p>
  
  <pre><code>const resultfilters = await this.reactionsRepository.find(filter)
  const reactions = (this.reactionsRepository.dataSource.connector as any).collection("Reactions");
    var collection = await reacciones.aggregate(
      [
        {"$group" : 
          {_id:{websiteId:'$' +,status:"$status"}, count:{$sum:1}}
        }, 
        {$sort:{"_id.source":1}}
      ]
    )
  </code></pre>