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 2010/12/18 10:25:04 UTC

[Couchdb Wiki] Trivial Update of "HTTP_view_API" by MarcelloNuccio

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "HTTP_view_API" page has been changed by MarcelloNuccio.
The comment on this change is: endkey_docid value is document id..
http://wiki.apache.org/couchdb/HTTP_view_API?action=diff&rev1=51&rev2=52

--------------------------------------------------

  ||'''startkey''' ||''key-value'' ||''-'' ||'''Must''' be a proper URL encoded JSON value ||
  ||'''startkey_docid''' ||''document id'' ||''-'' ||document id to start with ||
  ||'''endkey''' ||''key-value'' ||''-'' ||'''Must''' be a proper URL encoded JSON value ||
- ||'''endkey_docid''' ||''endkey_docid'' ||''-'' ||last document id to include in the output ||
+ ||'''endkey_docid''' ||''document id'' ||''-'' ||last document id to include in the output ||
  ||'''limit''' ||''number of docs'' ||''-'' ||Limit the number of documents in the output ||
  ||'''stale''' ||''ok'' ||''-'' ||If '''stale=ok''' is set CouchDB will not refresh the view even if it is stalled. ||
  ||'''descending''' ||''true / false'' ||''false'' ||reverse the output ||
@@ -137, +137 @@

  If a view contains both a map and reduce function, querying that view will by default return the result of the reduce function. The result of the map function only may be retrieved by passing ''reduce=false'' as a query parameter.
  
  The ''include_docs'' option will include the associated document. However, the user should keep in mind that there is a race condition when using this option. It is possible that between reading the view data and fetching the corresponding document that the document has changed. If you want to alleviate such concerns you should emit an object with a _rev attribute as in ''emit(key, {"_rev": doc._rev})''. This alleviates the race condition but leaves the possibility that the returned document has been deleted (in which case, it includes the ''"_deleted": true'' attribute). '''Note''': ''include_docs'' will cause a single document lookup per returned view result row. This adds significant strain on the storage system if you are under high load or return a lot of rows per request. If you are concerned about this, you can emit the full doc in each row; this will increase view index time and space requirements, but will make view reads optimally fast.
- 
  
  The ''inclusive_end'' option controls whether the ''endkey'' is included in the result. It defaults to true.
  
@@ -208, +207 @@

  There are no development plans to share code/functions between views.  Each view function is stored according to a hash of their byte representation, so it is important that a function does not load any additional code, changing its behavior without changing its byte-string.  Hence the use-case for [[http://github.com/couchapp/couchapp|CouchApp]]. In CouchApp, it is possible to include directives within any Javascript functions that directs CouchApp to modify the functions before they are uploaded to the CouchDb server.
  
  An explanation of CouchApp directives is found in [[http://japhr.blogspot.com/2010/02/couchapp-templates-for-showing.html|Chris Strom's blog]]. Using CouchApp, one can insert Javascript code from a different file into a view map function using the "code" CouchApp directive. For example:
+ 
  {{{#!highlight javascript
  {
-   "map": "function(doc) { 
+   "map": "function(doc) {
      // Next line is CouchApp directive
      // !code dir/file.js
  
@@ -221, +221 @@

    }"
  }
  }}}
- 
  Since CouchDB 0.11 it is possible to share code in {{{show}}}, {{{list}}}, {{{update}}}, and {{{validation}}} functions. See [[CommonJS_Modules]] for details.
  
  See also [[JavascriptPatternViewCommonJs|Javascript Pattern to Share Code Between View and Other Functions]]