incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From N/A N/A <pressley...@yahoo.com>
Subject Re: couchdb: function eval on insert, update...
Date Thu, 03 Nov 2011 14:48:59 GMT
algo utc_random will do the job for the uuid problem.

regards


________________________________
From: N/A N/A <pressley333@yahoo.com>
To: Nils Breunese <N.Breunese@vpro.nl>; "user@couchdb.apache.org" <user@couchdb.apache.org>
Sent: Thursday, November 3, 2011 4:25 PM
Subject: Re: couchdb: function eval on insert, update...

Yep. Sometimes it is useful. But i think not in this case, because insert/update already happened.
So i am doing another PUT/POST to update the document. 
I talk about document processing with server side logic before insert.

For example i want to know which document is last in my DB based on some criteria. How to
achieve that ? My _view is giving me all records with doc.name = "test", but which of those
"test" documents is last? I can use date ofc. But using date as criteria is dangerous since
date is outside server logic. Something/someone can change it. So last documents will not
be last.


________________________________
From: Nils Breunese <N.Breunese@vpro.nl>
To: "user@couchdb.apache.org" <user@couchdb.apache.org>; N/A N/A <pressley333@yahoo.com>
Sent: Thursday, November 3, 2011 3:59 PM
Subject: Re: couchdb: function eval on insert, update...

N/A N/A wrote:

> Any plans to implement doc features, like expression evaluation on insert or update in
CouchDB? For example:
> POST:
> {
> "test1": "1",
> "test2": "2",
> "test3": function(doc) {
> var res = doc.test1 + doc.test2
> return res;
> /* or maybe even                if (doc["test2"]) {
> doc["test4"]();
> } else {
> ... more stuff...
> }
> */
>     }
> "test4": function(doc_or_maybe_something_else) { ... }
> }
>
> result in couchdb:
> {
> "test1": "1",
> "test2": "2",
> "test3": "3"
> // ..etc.
> }

Document update handlers [0] can be used to invoke server-side logic to create or update a
document. Maybe you can use this to solve your use case?

Nils

[0] http://wiki.apache.org/couchdb/Document_Update_Handlers
------------------------------------------------------------------------
VPRO  www.vpro.nl
------------------------------------------------------------------------
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message