From 9c97bb531ed9b5d6fc18fcef87a6742514e984d5 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Fri, 20 Nov 2009 11:53:48 +0000 Subject: whitespace, add missing curly braces, 80 columns width -- no functionality change git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@882523 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch.js | 82 +++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 31 deletions(-) (limited to 'share/www/script/couch.js') diff --git a/share/www/script/couch.js b/share/www/script/couch.js index bac3881c..9f0995ff 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -37,16 +37,18 @@ function CouchDB(name, httpHeaders) { // Deletes the database on the server this.deleteDb = function() { this.last_req = this.request("DELETE", this.uri); - if (this.last_req.status == 404) + if (this.last_req.status == 404) { return false; + } CouchDB.maybeThrowError(this.last_req); return JSON.parse(this.last_req.responseText); } // Save a document to the database this.save = function(doc, options) { - if (doc._id == undefined) + if (doc._id == undefined) { doc._id = CouchDB.newUuids(1)[0]; + } this.last_req = this.request("PUT", this.uri + encodeURIComponent(doc._id) + encodeOptions(options), @@ -59,16 +61,19 @@ function CouchDB(name, httpHeaders) { // Open a document from the database this.open = function(docId, options) { - this.last_req = this.request("GET", this.uri + encodeURIComponent(docId) + encodeOptions(options)); - if (this.last_req.status == 404) + this.last_req = this.request("GET", this.uri + encodeURIComponent(docId) + + encodeOptions(options)); + if (this.last_req.status == 404) { return null; + } CouchDB.maybeThrowError(this.last_req); return JSON.parse(this.last_req.responseText); } // Deletes a document from the database this.deleteDoc = function(doc) { - this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id) + "?rev=" + doc._rev); + this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id) + + "?rev=" + doc._rev); CouchDB.maybeThrowError(this.last_req); var result = JSON.parse(this.last_req.responseText); doc._rev = result.rev; //record rev in input document @@ -78,7 +83,8 @@ function CouchDB(name, httpHeaders) { // Deletes an attachment from a document this.deleteDocAttachment = function(doc, attachment_name) { - this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id) + "/" + attachment_name + "?rev=" + doc._rev); + this.last_req = this.request("DELETE", this.uri + encodeURIComponent(doc._id) + + "/" + attachment_name + "?rev=" + doc._rev); CouchDB.maybeThrowError(this.last_req); var result = JSON.parse(this.last_req.responseText); doc._rev = result.rev; //record rev in input document @@ -89,14 +95,16 @@ function CouchDB(name, httpHeaders) { // first prepoulate the UUIDs for new documents var newCount = 0 for (var i=0; i