couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Benesch <ja...@realestatetomato.com>
Subject Re: Best practise handling request and creating new document?
Date Sun, 30 May 2010 23:04:59 GMT
>
> "Instead of printing out the title I'm going to validate it and create a
> new document with it. How can I do that? Whats the best practise, should I
> perhaps using something else than a show?"


The validation should be done using javascript on your ddoc (design
document).  The validate_doc_update function handles the validation.
Look here:
http://books.couchdb.org/relax/design-documents/validation-functions

"I'm not going to submit a <form> using client side JavaScript and for
> example an AJAX HTTP PUT request. I'm going to send the form directly to
> CouchDB and let it handle the data and create new documents"


Why not use client side javascript? You have to send a HTTP request to couch
one way or another to submit the document. You can either use javascript or
a server side language.


On Fri, May 28, 2010 at 7:14 PM, <hever@gmx.net> wrote:

> Hello,
>
> I'm trying to find out, how I can create new documents from a web formula
> request using just CouchDB.
>
> I'm not going to submit a <form> using client side JavaScript and for
> example an AJAX HTTP PUT request. I'm going to send the form directly to
> CouchDB and let it handle the data and create new documents.
>
> I'm new to CouchDB and currently I'm just seeing a solution in using shows:
> http://books.couchdb.org/relax/design-documents/shows
>
> This show "book" prints out the title of an existing document if its given.
> Shows a "New book" form if no existing document is given and prints out the
> title if the form is submitted.
>
> {
>  "book": "function(doc, req) {
>     if( req.query.title ){
>         return req.query.title;
>     }
>     else if( doc )
>         return doc.title;
>     else
>         return '<form><input name=\"title\"><input
> type=\"submit\"></form>';
>
>     }"
> }
>
> Instead of printing out the title I'm going to validate it and create a new
> document with it. How can I do that? Whats the best practise, should I
> perhaps using something else than a show?
>
> I did not found the JS API documentation, exists one?
>
> Thanks in advance!
> Philipp
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>



-- 
Jason Benesch

We just launched www.TomatoUniversity.com - Join for free!
Technology Training for the Real Estate Industry.

Real Estate Tomato
Co-owner
www.realestatetomato.com
(619) 770-1950
jason@realestatetomato.com

ListingPress
Owner, Founder
www.listingpress.com
(619) 955-7465
jason@listingpress.com

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