You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Vikkie Johl <vi...@gmail.com> on 2012/10/01 12:58:27 UTC
Analytics Using validate_doc_update
Hi !,
Whenever I save a new document, I want perform some analytics based on the
previously (last) saved document. Is there any way I go do the same, I
tried using validate_doc_update but not much help.
Regards,
Vikkie
Re: Analytics Using validate_doc_update
Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 1 October 2012 12:58, Vikkie Johl <vi...@gmail.com> wrote:
> Hi !,
>
> Whenever I save a new document, I want perform some analytics based on the
> previously (last) saved document. Is there any way I go do the same, I
> tried using validate_doc_update but not much help.
>
> Regards,
> Vikkie
Hey Vikkie,
I moved this to user@ as it's more appropriate. Welcome to CouchDB :-)
function(newDoc, oldDoc, userCtx) { … stuff …}
This is the spec for a validation function[1]. So you have all the
oldDoc version available to play with**
I assume you mean last saved version of the same doc, and not the n-1
doc that was PUT.
Don't forget that:
- the oldDoc will only be available if you are providing an id either
in the URL or in the doc body
- the validation function is also run during replication
- not all versions of a document are passed during replication, only
the latest leaf docs on each branch***
[1]: http://guide.couchdb.org/draft/validation.html
[2]: http://wiki.apache.org/couchdb/Document_Update_Validation
**: caveat that you can't get to the body of attachments, you can only
read the stubs.
***: hand-wavey
Re: Analytics Using validate_doc_update
Posted by Dave Cottlehuber <dc...@jsonified.com>.
Replied on user@.
On 1 October 2012 12:58, Vikkie Johl <vi...@gmail.com> wrote:
> Hi !,
>
> Whenever I save a new document, I want perform some analytics based on the
> previously (last) saved document. Is there any way I go do the same, I
> tried using validate_doc_update but not much help.
>
> Regards,
> Vikkie