algo utc_random will do the job for the uuid problem.

regards


________________________________
From: N/A N/A <[email protected]>
To: Nils Breunese <[email protected]>; "[email protected]" 
<[email protected]>
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 <[email protected]>
To: "[email protected]" <[email protected]>; N/A N/A 
<[email protected]>
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
------------------------------------------------------------------------

Reply via email to