couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Marino <mmar...@gmail.com>
Subject Re: Post Insert Validation
Date Fri, 26 Sep 2014 09:02:00 GMT
Hi Conor,

On Fri, Sep 26, 2014 at 10:57 AM, Conor Mac Aoidh <conormacaoidh@gmail.com>
wrote:

> Hi All,
>
> I was previously using the validate_doc_update function for document
> validation. However, now I need to be able to change the contents of a
> document if it is invalid.
>

validate_doc_update only gives you a yes or no as you point out.


> I was wondering what the best way to go about this is? Is there any design
> function that executes after a document insert and that will allow me to
> edit the document contents. I understand this will result in an additional
> revision.
>

You can change the contents of a document (either in place or newly
submitted) using a update function.  Your update function could check to
make sure something is correct and modify if necessary.  The only caveat is
that you must always explicitly POST or PUT to the update function, so this
would require a change in your user app.  I think, however, this is likely
the best solution for you.  (see
http://docs.couchdb.org/en/latest/couchapp/ddocs.html#update-functions)

Cheers,
Mike

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