Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 7696 invoked from network); 31 May 2010 21:10:35 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 31 May 2010 21:10:35 -0000 Received: (qmail 63120 invoked by uid 500); 31 May 2010 21:10:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 63075 invoked by uid 500); 31 May 2010 21:10:34 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 63063 invoked by uid 99); 31 May 2010 21:10:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 May 2010 21:10:34 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of hever@gmx.net designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 31 May 2010 21:10:27 +0000 Received: (qmail 6085 invoked by uid 0); 31 May 2010 21:10:06 -0000 Received: from 95.223.227.129 by www040.gmx.net with HTTP; Mon, 31 May 2010 23:10:06 +0200 (CEST) Cc: dev@couchdb.apache.org Content-Type: text/plain; charset="utf-8" Date: Mon, 31 May 2010 23:10:06 +0200 From: hever@gmx.net In-Reply-To: <20100531002722.196210@gmx.net> Message-ID: <20100531211006.150540@gmx.net> MIME-Version: 1.0 References: <20100529021456.177470@gmx.net> <20100531002722.196210@gmx.net> Subject: Re: Best practise handling request and creating new document? To: user@couchdb.apache.org X-Authenticated: #5210232 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1+UWzE95ZOU1z27Hrd11eC1U1AHR/12ZHsNWnIhiq Xr1uvjBd7BIASGEgGARRdzCJkrDL3j7+Fr6A== Content-Transfer-Encoding: 8bit X-GMX-UID: +WFOC4Zda2AoUxy2eHQy2+46OWhhages X-FuHaFi: 0.41999999999999998 X-Virus-Checked: Checked by ClamAV on apache.org Hello, http://books.couchdb.org/relax/design-documents/shows#Side-Effect%20Free says: > We’ve mentioned that a key constraint of show functions is that they are side > effect free. This means that you can’t use them to update documents, kick off > background processes, or trigger any other function. > CouchDB takes a different tack: because we’re a database, not an > application server, we think it’s more important to enforce best practices (and > ensure that developers don’t write functions that adversely effect the database > server) than offer absolute flexibility. Once you’re used to working within these > constraints, they start to make a lot of sense. I'm a CouchDB beginner and not fixed on shows or other methods. I'm going to know if there is any way to manipulate data or insert data using a HTML form / request and just CouchDB without client side JS or some kind of application layer? Thanks so far! Philipp -------- Original-Nachricht -------- > Datum: Mon, 31 May 2010 02:27:22 +0200 > Von: hever@gmx.net > An: user@couchdb.apache.org > Betreff: Re: Best practise handling request and creating new document? > > -------- Original-Nachricht -------- > > Datum: Sun, 30 May 2010 16:04:59 -0700 > > Von: Jason Benesch > > 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
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, 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 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 ' > > type=\"submit\">'; > > > > > > }" > > > } > > > > > > 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 -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01