Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Hi,

I am creating a site where users can set up budgets for themselves.

As part of this, they create a cloned page for each 'expense', with the cost in the 'expense_cost' field on the cloned pages.

Is there a way to sum all the 'expense_cost' fields? E.g. If there are four cloned pages with the 'expense_cost' or 4, 7, 10, 3 then the sum will be 24. Is it possible to loop through all these pages and use the cms:add tag?
If the number of pages is small, then there is no harm looping them all with cms:pages and fetch the required editable. Some global variable can hold the sum. So recieve data from db and then sum it up.

Once the number of pages is big, then it is advisable to sum values by the means of mysql database itself. And then get from the db the result. It is marginally faster (10x-100x) for a big number of pages.
2 posts Page 1 of 1
cron