Cumulative computation with RavenDB queries December 7, 2021 Author: Oren Eini, CEO RavenDB
Read the orginal blog post

Cumulative computation with RavenDB queries

by Oren Eini, CEO RavenDB December 7, 2021

imageConsider the image on the right, where we have three charges on separate months. This is a time series, showing charges over time. We can very easily issue queries that will give us the results of how much we paid in a time period, but what if we wanted to get the cumulative value. How much have I paid so far? Here is how this should look like:

image

However, that is not something that we provide in RavenDB. Luckily, we do provide a very flexible query engine, so we can make it happen anyway. Here is what the query will look like:

Note that we are using a JavaScript function to process the time series and run the computation that we want, and then we return an array, which is translated to multiple results set per document. Here is the result of this query:

image


Share your thoughts or ask us a question

Categories: