couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Best practise handling request and creating new document?
Date Sat, 29 May 2010 02:14:56 GMT

I'm trying to find out, how I can create new documents from a web formula request using just

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:

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;
         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!

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter

View raw message