incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject Re: couchdb: function eval on insert, update...
Date Thu, 03 Nov 2011 15:13:00 GMT
N/A N/A wrote:

> 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.

AFAIK document update handlers run before the document is created/updated, so I guess it would
just work for your use case.

> 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.

You could use a document update handler to have the server set a last modified date property
on your documents. You could also maybe just query the _changes feed for a database: /<database>/_changes?limit=1

Nils.
------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------

Mime
View raw message