You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Zachary Zolton <za...@gmail.com> on 2010/07/26 20:57:53 UTC

Re: question on CouchDB views: how to use a query sting (formula) in the view

A _list function is the appropriate place to write
dynamic/param-driven code that operates on the results of a view
query.

http://wiki.apache.org/couchdb/Formatting_with_Show_and_List
http://books.couchdb.org/relax/design-documents/lists

Cheers,
Zach

On Mon, Jul 26, 2010 at 1:23 PM, Fink Mark <ma...@mark-fink.de> wrote:
> Hi there,
>
> I am using CouchDB for some time now and now I am stuck with the following
> question.
>
> Lets say I store some values from some Physics experiments in couchdb:
>
> ID   x1   x2
> 1     1     1.1
> 2     2     1.2
> 3     3     1.3
> 4     4     1.4
> ...
>
> Now I want to do some calculations within couchdb (NOT on the client side).
> Lets say I want to apply some formulas:
> y1 = 1*x1 + 0.5*x2*x2
> y2 = 1/3*x1 + 0.7*x2*x2*x2
> ...
>
> I am thinking about passing the formula as a parameter to the view. Is this
> possible without using eval and does the caching still work like if I apply
> the same formula again it is faster? Maybe there is a sample available?
>
> For a RDBMS I would probably do something like that:
> select (1*x1 + 0.5*x2*x2) as y1 from experiments;
>
> Please do not tell me that I have to use a different view for each formula
> because this is not possible besides it is possible to create new views
> dynamically when needed.
>
>
> Regards
> Mark
>