You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2012/06/28 13:41:05 UTC
[Couchdb Wiki] Trivial Update of "Working_with_Forms" by DaveCottlehuber
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Working_with_Forms" page has been changed by DaveCottlehuber:
http://wiki.apache.org/couchdb/Working_with_Forms?action=diff&rev1=1&rev2=2
Comment:
use working function instead, doh.
doc._id = request.form.email
}
}
- var resp = {
- 'headers' : {
- 'Content-Type' : 'application/json'
- },
- 'body' : toJSON({"request": request, "previous": previous, "doc": doc})
+ return [doc, toJSON({"request": request, "previous": previous, "doc": doc})]
- }
- return [doc, resp]
}
}}}
@@ -148, +142 @@
}}}
* Next comes the {{{_id}}} of the previous document version, for example if we were doing a PUT request, this would be filled, along with a {{{_rev}}} revision as well.
- * The requested path is provided in several forms, to make it easier to match update handlers with document rewrite rules.
+ * The requested path is provided in several forms, to make it easier to match update handlers with document rewrite rules.
- * If any {{{query}}} parameters were passsed to the URL, they would also be accessible.
+ * If any {{{query}}} parameters were passsed to the URL, they would also be accessible. * The full headers are available as usual.
- * The full headers are available as usual.
{{{
…
@@ -214, +207 @@
=== Emitting the result during testing ===
- Finally we emit the resulting document, after our server-side update handler has run. Note that the revision {{{_rev}}} is not yet available.
+ Finally we emit the resulting document, after our server-side update handler has run. Note that the revision {{{_rev}}} is not yet available, but as noted in [[Document_Update_Handlers]] it is possible to retrieve this.
+
{{{
…
doc: {
@@ -234, +228 @@
After the write was successful we can retrieve the new document:
{{{
- $ curl --silent -HContent-Type:application/json -vXGET $DB/john@example.org | json_reformat
+ $ curl --silent -HContent-Type:application/json -vXGET http://localhost:5984/simpleform/john@example.org | json_reformat
* About to connect() to localhost port 5984 (#0)
* Trying ::1... Connection refused
@@ -247, +241 @@
> Content-Type:application/json
>
< HTTP/1.1 200 OK
- < Server: CouchDB/1.2.0 (Erlang OTP/R15B01)
+ < Server: CouchDB/1.3.0a- (Erlang OTP/R15B01)
- < ETag: "1-389cd40f8d8317427a9d7ee9c24a0c81"
+ < ETag: "1-5c316da64caebbebcd0f87364df2a0e7"
- < Date: Thu, 28 Jun 2012 11:13:34 GMT
+ < Date: Thu, 28 Jun 2012 11:31:49 GMT
< Content-Type: text/plain; charset=utf-8
- < Content-Length: 237
+ < Content-Length: 228
< Cache-Control: must-revalidate
<
{ [data not shown]
@@ -259, +253 @@
* Closing connection #0
{
"_id": "john@example.org",
+ "_rev": "1-5c316da64caebbebcd0f87364df2a0e7",
- "_rev": "1-389cd40f8d8317427a9d7ee9c24a0c81",
- "form": {
- "name": "John Doe",
+ "name": "John Doe",
- "phone": "+1 (234) 987-654",
+ "phone": "+1 (234) 987-654",
- "email": "john@example.org",
+ "email": "john@example.org",
- "url": "http://john.blogger.com/",
+ "url": "http://john.blogger.com/",
- "message": "STILL NO CHEEZBURGER?",
+ "message": "STILL NO CHEEZBURGER?",
- "submit": "submit"
+ "submit": "submit"
- }
}
}}}