RavenDB's Dynamic Reporting
Join the DZone community and get the full member experience.
Join For Freeone of the nice things about having more realistic demo data set is that we can now actually show demos on that data. i didn’t realize how much of an issue that was until we actually improved things.
let us see how we are going to demo ravendb’s dynamic reporting feature.
we start by creating the following index. it is a pretty simple one, with the one thing to notice is that we are explicitly setting the sort mode for total to be double.
now that we have done that, we are going to go to query > reporting:
and then i can start issue reporting queries:
this is the equivalent of doing:
select employeeid, sum(tot.total) total from orders o join ( select sum((quantity * unitprice) * (1- discount)) total, orderid from [order details] group by orderid ) tot on o.orderid = tot.orderid where o.customerid = @customerid group by employeeid
the nice thing about this, and what makes this feature different from standard map/reduce, is that you can filter the input data into the aggregation.
in code, this would look something like this:
session.query<order>("orders/total") .where(x=>x.company = companyid) .aggregateby(x=>x.employee) .sumon(x=>x.total) .tolist();
pretty nice, even if i say so myself.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Micro Frontends on Monorepo With Remote State Management
-
4 Expert Tips for High Availability and Disaster Recovery of Your Cloud Deployment
-
Which Is Better for IoT: Azure RTOS or FreeRTOS?
-
RAML vs. OAS: Which Is the Best API Specification for Your Project?
Comments