Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource transformation #88

Open
diegomvh opened this issue Jun 6, 2024 · 2 comments
Open

Resource transformation #88

diegomvh opened this issue Jun 6, 2024 · 2 comments

Comments

@diegomvh
Copy link
Owner

diegomvh commented Jun 6, 2024

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 #86 (comment)

@diegomvh
Copy link
Owner Author

diegomvh commented Jun 6, 2024

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);
});

@hakimio
Copy link

hakimio commented Jul 25, 2024

@diegomvh
Was this implemented in 0.128.0? Can you give a small summary of what changed in 0.128.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants