alfateam / orange-orm

The ultimate ORM for Node and Typescript
https://orange-orm.io
ISC License
623 stars 20 forks source link

Aggregate operators on relations #80

Closed lroal closed 2 months ago

lroal commented 2 months ago
const order = await db.order.getById(1, {
  lineCount: x => x.count(x => x.lines)
});
console.dir(order.lineCount);

With filter

const order = await db.order.getById(1, {
  lineCount: x => x.count(x => x.lines, {
    lines:  {
      where: x => x.product.contains('broomstick'),
      limit: 20,
      orderBy: 
    }
  })
});
console.dir(order.lineCount);