couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suraj Kumar <suraj.ku...@inmobi.com>
Subject Proposal for new feature: Auto Update Functions
Date Fri, 30 May 2014 10:57:14 GMT
[x-posted]

Hi,

This email is to propose a new feature in CouchDB, specifically, a new type
of design document, called "Auto Update Functions". The intention is to
describe this and see whether the community would like to see this feature
in CouchDB and if yes, then get into the act of preparing a patch for
CouchDB.

*What are "Auto Update Functions"?*
We often have use-cases where we want to introduce or mutate attribute in a
document based on a code computable state of the document. *Auto Update
Functions* will be invoked for each document being updated after VDU (if
any) passes. The return value of the AUF is persisted on disk instead of
the actual doc sent in the request.

This way, features such as appending the last modified timestamp to a
document being modified, or adding which user modified a document or
computing the 'state' of an object can all be done via Auto Update
Functions.

Currently, we solve these use-cases through an external agent which
subscribes to Changes API and writes back to the very documents. But this
brings in all sorts of operational headaches (how do we ensure this
external agent will be highly available? would it use a 'queue' to keep
track of messages to be processed? ultimately, Changes API does not give
all we need either (ex: time of modification, user who modified the doc,
old doc (too late?), etc.,).

*Auto Update Function structure*

At the design doc level, it would look much similar to a Validate Doc
Update function:

function (NewDoc, OldDoc, UserCtx) {
    // Mutate NewDoc here
    return NewDoc;
}

What are your thoughts, both from the use-case as well as
internals/performance of CouchDB about this?

Regards,

  -Suraj

-- 
An Onion is the Onion skin and the Onion under the skin until the Onion
Skin without any Onion underneath.

-- 
_____________________________________________________________
The information contained in this communication is intended solely for the 
use of the individual or entity to whom it is addressed and others 
authorized to receive it. It may contain confidential or legally privileged 
information. If you are not the intended recipient you are hereby notified 
that any disclosure, copying, distribution or taking any action in reliance 
on the contents of this information is strictly prohibited and may be 
unlawful. If you have received this communication in error, please notify 
us immediately by responding to this email and then delete it from your 
system. The firm is neither liable for the proper and complete transmission 
of the information contained in this communication nor for any delay in its 
receipt.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message