Changeset 446
- Timestamp:
- 06/08/13 17:43:13 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/qed-client/store/CouchStore.js
r443 r446 1 1 define([ 2 'dojo/_base/array',3 'dojo/_base/declare',4 'dojo/_base/Deferred',5 'dojo/_base/json',6 'dojo/_base/lang',7 'dojo/_base/xhr',8 'dojo/store/util/QueryResults'9 ], function(array,declare,Deferred,json,lang,xhr,QueryResults){2 "dojo/_base/Deferred", 3 "dojo/_base/array", 4 "dojo/_base/declare", 5 "dojo/_base/json", 6 "dojo/_base/lang", 7 "dojo/request", 8 "dojo/store/util/QueryResults" 9 ], function(Deferred, array, declare, json, lang, request, QueryResults) { 10 10 11 11 function getCouchError(err){ … … 39 39 info: function(){ 40 40 var dfd = new Deferred(); 41 xhr("GET", {42 url: this.target,41 request(this.target, { 42 method: "GET", 43 43 handleAs: "json", 44 44 headers: { … … 58 58 get: function(id){ 59 59 var dfd = new Deferred(); 60 xhr("GET", { 61 url: this.target + id, 62 handleAs: "json", 63 headers: { 64 Accept: this.accepts 65 } 66 }).then(function(result){ 67 if ( result.error ) { 68 dfd.reject(result.reason); 69 } else { 60 request(this.target + encodeURIComponent(id), { 61 method: "GET", 62 handleAs: "json", 63 headers: { 64 Accept: this.accepts 65 } 66 }).then(function(result){ 67 if ( result.error ) { 68 dfd.reject(result.reason); 69 } else { 70 result[this.idProperty] = result[this._responseIdProperty]; 71 result[this.revProperty] = result[this._responseRevProperty]; 70 72 dfd.resolve(result); 71 73 } … … 101 103 var id = options.id ? options.id : this.getIdentity(object); 102 104 var hasId = typeof id !== "undefined"; 103 xhr(hasId ? "PUT" : "POST", {104 url: hasId ? this.target + id : this.target,105 postData: json.toJson(object),105 request(hasId ? this.target + encodeURIComponent(id) : this.target, { 106 method: hasId ? "PUT" : "POST", 107 data: json.toJson(object), 106 108 handleAs: "json", 107 109 headers:{ … … 127 129 remove: function(id,rev){ 128 130 var dfd = new Deferred(); 129 xhr("DELETE",{130 url: this.target + id,131 request(this.target + encodeURIComponent(id), { 132 method: "DELETE", 131 133 headers: { 132 134 'If-Match': rev … … 237 239 } 238 240 239 for ( var qp in queryOpts) {240 queryOpts[ qp] = json.toJson(queryOpts[qp]);241 } 242 query += '?' + xhr.objectToQuery(queryOpts);243 244 xhr("GET", {245 url: this.target + query,246 handleAs: "json",241 for ( var opt in queryOpts ) { 242 queryOpts[opt] = json.toJson(queryOpts[opt]); 243 } 244 245 request(this.target + query, { 246 method: "GET", 247 handleAs: "json", 248 query: queryOpts, 247 249 headers: { 248 250 Accept: this.accepts
Note: See TracChangeset
for help on using the changeset viewer.