Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return etag for database views

  • Loading branch information...
commit be25759646c79a52de588396d178c0115c496522 1 parent 9cba362
Nathan authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 lib/couchdb/database.js
View
18 lib/couchdb/database.js
@@ -182,6 +182,16 @@ Database = {
return this._findSingleDoc(idOrArrayOfIds);
}
},
+ /**
+ * Retrieve a couchdb view.
+ * @param designDocName
+ * @param viewName
+ * @param options
+ * @returns An object with 'rows', 'total_rows', and 'etag' properties.
+ * 'rows' contains the results of the view.
+ * 'total_rows' contains the total number of rows indexed by the view.
+ * 'etag' contains the etag generated for the view by CouchDB
+ */
view: function(designDocName, viewName, options) {
var viewResult;
var keys;
@@ -206,6 +216,14 @@ Database = {
viewResult = data;
viewResult.totalRows = viewResult.total_rows;
},
+ complete: function(xhr, textStatus) {
+ var etag;
+
+ etag = xhr.getResponseHeader("Etag");
+ if (typeof etag == "string") {
+ viewResult.etag = etag;
+ }
+ },
error: function(xhr, textStatus, errorThrown) {
throw new Error(textStatus + ": " + (errorThrown || ""));
}
Please sign in to comment.
Something went wrong with that request. Please try again.