[Couchdb Wiki] Update of Document revisions by PatrickAntivackis
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The following page has been changed by PatrickAntivackis: http://wiki.apache.org/couchdb/Document_revisions -- Due to compaction, revisions may disappear at any time. You cannot use them for a client revision system. + [Replication] has also an impact on revisions, i.e. '''Replication only replicates the last version of a document''', so the it will be impossible to access, on the destination database, previous versions of a document that were store on the source database. + If you wish to implement revisions in your client system a number of patterns have been suggested: * Using attachments to store old revisions.
[Couchdb Wiki] Update of Replication by PatrickAntivackis
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The following page has been changed by PatrickAntivackis: http://wiki.apache.org/couchdb/Replication New page: == Overview == The replication is an incremental one way process involving two databases (a source and a destination). The aim of the replication is that at the end of the process, all active documents on the source database are also in the destination database and all documents that were deleted in the source databases are also deleted (if exists) on the destination database. The replication process only copy the last revision document, so all previous revision that were only on the source database are not copied to the destination database.
[Couchdb Wiki] Update of Formatting with Show and List by PaulDavis
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The following page has been changed by PaulDavis: http://wiki.apache.org/couchdb/Formatting_with_Show_and_List The comment on the change is: Redirect example -- } }}} + + == Other Fun Things == + + === Stopping iteration in a `_list` === + + If you want to terminate iteration of a `_list` early you can return a `{stop: true}` JSON object from any of the calls to the function that include a row object. + + === Sending a Redirect === + + In the call to `_show` or when `_list` is called with a head object you can control the headers and status code sent to the client. An example of this would be to send a redirect notification. + + {{{ + function(doc) + { + return {code: 302, body: See other, headers: {Location: /}}; + } + }}} + + {{{ + function(head, row, req, row_info) { + if (head) { + return {code: 302, body: See other, headers: {Location: /}}; + } else if (row) { + return {stop: true}; + } else { + return . + } + } + }}} + Hopefully this is enough to get started. For a more complete set of examples, see the CouchDB test suite, especially show_documents.js and list_views.js
[Couchdb Wiki] Update of Formatting with Show and List by JensAlfke
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The following page has been changed by JensAlfke: http://wiki.apache.org/couchdb/Formatting_with_Show_and_List The comment on the change is: Added details about 'head' and 'row_info'. -- A list function has a more interesting signature, as it is passed the head of the view on first invocation, then each row in turn, then called one more time for the tail of the view. The function should check the `head` and `row` parameters to identify which state it's being called in; the sequence of calls to `listfn`, for a view with three rows, would look like: {{{ - listfn(true, null , req, null); // Before the first row: head=true + listfn(head, null,req, null); // Before the first row: head is non-null - listfn(false, rows[0], req, row_info); // First row: head=false + listfn(null, rows[0], req, row_info); // First row - listfn(false, rows[1], req, row_info); // Subsequent rows... + listfn(null, rows[1], req, row_info); // Subsequent rows... - listfn(false, rows[2], req, row_info); + listfn(null, rows[2], req, row_info); - listfn(false, null,req, row_info); // After last row: row=null + listfn(null, null,req, row_info); // After last row: row=null }}} - List functions also have the ability to abort iteration early, which is handy for some filtering operations. + The `head` parameter -- which is only passed into the first call -- contains an object with information about the view that is to be iterated over. It's much like the response object returned from a view query in the CouchDB JavaScript API; useful properties include `total_rows` and `offset`. + + The `row_info` parameter contains an object with information about the iteration state. Its properties include: + * `row_number` (the current row number) + * `first_key` (the first key of the view to be listed) + * `prev_key` (the key of the row in the previous iteration) Example list function:
[Couchdb Wiki] Trivial Update of Formatting with Show and List by JensAlfke
Dear Wiki user, You have subscribed to a wiki page or wiki category on Couchdb Wiki for change notification. The following page has been changed by JensAlfke: http://wiki.apache.org/couchdb/Formatting_with_Show_and_List The comment on the change is: Oops, fixed list formatting -- The `head` parameter -- which is only passed into the first call -- contains an object with information about the view that is to be iterated over. It's much like the response object returned from a view query in the CouchDB JavaScript API; useful properties include `total_rows` and `offset`. The `row_info` parameter contains an object with information about the iteration state. Its properties include: - * `row_number` (the current row number) + * `row_number` (the current row number) - * `first_key` (the first key of the view to be listed) + * `first_key` (the first key of the view to be listed) - * `prev_key` (the key of the row in the previous iteration) + * `prev_key` (the key of the row in the previous iteration) Example list function: