Skip to content

Releases: alfateam/orange-orm

v3.10.0

11 May 20:44
Compare
Choose a tag to compare

Now supporting aggregates

You can count records and aggregate numerical columns. This can either be done across rows or separately for each row.
Supported functions include:

  • count
  • sum
  • min
  • max
  • avg

The aggregate function effeciently groups data together.
In this particular example , for each customer, it counts the number of lines associated with their orders and calculates the total amount of these lines.
Under the hood, it will run an sql group by customerId and customerName.

import map from './map';
const db = map.sqlite('demo.db');

getAggregates();

async function getAggregates() {
  const orders = await db.order.aggregate({
    where: x => x.orderDate.greaterThan(new Date(2022, 0, 11, 9, 24, 47)),
    customerId: x => x.customerId,
    customerName: x => x.customer.name,
    numberOfLines: x => x.count(x => x.lines.id),
    totals: x => x.sum(x => lines.amount)    
  });
}

v3.9.0

08 May 08:09
Compare
Choose a tag to compare

Possible to elevate associated column on a related table to a parent table when fetching. Example with the customer.balance column below.

  const orders = await db.order.getAll({
    balance: x => x.customer.balance
  });

v3.8.0

04 May 06:06
Compare
Choose a tag to compare

Aggregate operators

  const orders = await db.order.getAll({
    numberOfLines: x => x.count(x => x.lines.id),
    totalAmount: x => x.sum(x => x.lines.amount),
    minAmount: x => x.min(x => x.lines.amount),
    maxAmount: x => x.max(x => x.lines.amount),
    avgAmount: x => x.avg(x => x.lines.amount),
  });

v.3.7.0

13 Apr 09:50
Compare
Choose a tag to compare

What's Changed

  • mysql@3.9.4 and tedious@18.1.0 by @lroal in #79

Full Changelog: v3.6.2...v3.7.0

v3.6.2

10 Apr 10:16
Compare
Choose a tag to compare

Bug fix:
getMany with orderBy an array throws after v3.6.0

v3.6.1

02 Apr 07:10
4804c19
Compare
Choose a tag to compare

What's Changed

  • Fixed bug in filtered relations regarding incorrect alias by @lroal in #76

v3.6.0

15 Mar 15:54
Compare
Choose a tag to compare

Filtering relations

v3.5.2

01 Feb 14:40
Compare
Choose a tag to compare

MssqlNative and SAP ASE: PRINT statements no longer yields error.

v3.5.1

24 Jan 12:41
Compare
Choose a tag to compare

v3.5.0

23 Jan 19:04
Compare
Choose a tag to compare

Now supporting Oracle