couchdb-user mailing list archives

-------- Original-Nachricht --------
> Datum: Sun, 30 May 2010 16:04:59 -0700
> Von: Jason Benesch <jason@realestatetomato.com>
> An: user@couchdb.apache.org
> Betreff: Re: Best practise handling request and creating new document?
> >
> > "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
Good hint, thank you!
>
> "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.
>
I'm not going to use client side JS because I'm going to write a public web application. In
my opinion it's really no good practice to write the application in a way, that it's just
usable with JS.
Furthermore I'm not going to use a classic server side scripting language because I'm really
enthused by the concept of having data and program in one storage with the ability to replicate
both at once. It's nice to be able to share data and program at once with other people or
let them replicate/download and use the "web application" locally.
I'm new to CouchDB but as I see it, CouchDB can do much more than a normal data storage would
do. The ability to render HTML Templates or to handle Requests is nice but at least only really
useful if it gives you the power to manipulate data. If this is not possible this bunch of
functionallity is nice but not really complete or usable. In such a case it would be perhaps
better to use another application layer and drop those things from CouchDB thinking of performance,
security, complexity and so on...
http://localhost:5984/_utils/script/test/update_documents.js gives some ideas and the functionallity
exists but as I'm new I can't really go on with this:
> var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
> db.deleteDb();
> db.createDb();
> var doc = {"word":"plankton", "name":"Rusty"}
> var resp = db.save(doc);
> xhr = CouchDB.request("PUT", "/test_suite_db/_design/update/_update/in-place/"+docid+'?field=title&value=test');
CouchDB seems not usable in this context...
> new ReferenceError(\"CouchDB is not defined\", \"\", 4)
I belive there is some way doing it and I hope somebody will help me.
Thanks so far!
>
> 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
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01