You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Suraj Kumar <su...@inmobi.com> on 2013/09/17 16:29:58 UTC

Change document in validate_doc_update

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.

Re: Change document in validate_doc_update

Posted by Robert Newson <rn...@apache.org>.
"How can end users like me achieve the same for my business logic
and altogether bypass the need to write middleware code?"

It's not currently available to users though I believe that's planned.

B.

On 17 Sep 2013, at 15:29, Suraj Kumar <su...@inmobi.com> wrote:

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


Re: Change document in validate_doc_update

Posted by Max Thayer <ma...@cloudant.com>.
Hey Suraj!

Will update handlers<http://docs.couchdb.org/en/latest/ddocs.html#update-functions>do
the trick?

Best regards,
Max <http://www.maxthayer.org/>


On Tue, Sep 17, 2013 at 10:29 AM, Suraj Kumar <su...@inmobi.com>wrote:

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