couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suraj Kumar <suraj.ku...@inmobi.com>
Subject Change document in validate_doc_update
Date Tue, 17 Sep 2013 14:29:58 GMT
I'd like to add extra fields to the document being created, just like how
_user works.

These I'd like to be able to compute using the inputs provided by the user,
in perhaps, something like a validate function.

I tried doing the following, in many different variations, knowing well
that this is only wishful thinking... and as expected, it didn't work:

function (newDoc, oldDoc, userCtx) { newDoc['newField'] = 10; return
newDoc; }

But I'd very much like to do what the _user database does - where by
setting password, the document ends up getting different fields. How is it
achieved? How can end users like me achieve the same for my business logic
and altogether bypass the need to write middleware code? (I'm having to
write middle ware code just to transform one json hash into another because
my system is a pure API. CouchApps won't just do it (complex,
already-existent-clients will use the API)).

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