angular-odata
angular-odata copied to clipboard
Resource transformation
Can you tell me how can I migrate the following code:
// ODataEntitySetService<OrderSummaryItem>
this.orderService
.entities()
.query(q => {
q.apply({
transform: {
// filters: string
filter: filters,
groupBy: {
properties: ['status'],
transform: {
aggregate: {
orderProductValue: {
with: StandardAggregateMethods.sum,
as: 'totalOrderValue'
},
ID: {
with: StandardAggregateMethods.countdistinct,
as: 'totalOrders'
}
}
}
}
}
});
})
.fetch();
It seems the new apply() method version only accepts function or string.
EDIT: Should I use restore() instead of apply()?
Would be nice to have some kind of Changelog with the new release to see at least any breaking changes.
Originally posted by @hakimio in https://github.com/diegomvh/angular-odata/issues/86#issuecomment-2126617551
WIP
const transform = recs.transform<{ directory: string, total: number, count: number, average: number }>(({ e, t }) => e()
.filter(({ e, t }) => e().lt(t.fecha, new Date()))
.groupBy(() => [t.directory],
f => f.sum(t.size, 'total')
.countdistinct(t.contentType, 'count')
.average(t.size, 'average')
));
transform.query(q => {
q.orderBy(({ e, t }) => e().descending(t.total));
})
console.log(recs.toString());
console.log(transform.toString());
transform.fetchCollection().subscribe((col) => {
console.log(col);
});
@diegomvh
Was this implemented in 0.128.0? Can you give a small summary of what changed in 0.128.0?