Changeset 362 for Dev/branches/rest-dojo-ui/client/rft/store.js
- Timestamp:
- 07/16/12 16:27:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/store.js
r359 r362 97 97 if ( query === undefined ) { 98 98 query = '_all_docs'; 99 queryOpts.include_docs = true;100 99 } 101 100 … … 126 125 127 126 // Custom options 128 if (options.key ) {127 if (options.key !== undefined) { 129 128 queryOpts.key = options.key; 130 } else if (options.keys ) {129 } else if (options.keys !== undefined) { 131 130 queryOpts.keys = options.keys; 132 } else if (options.startkey || options.endkey) {131 } else if (options.startkey !== undefined || options.endkey !== undefined) { 133 132 queryOpts.startkey = options.startkey; 134 133 queryOpts.endkey = options.endkey; 134 } 135 if (options.include_docs !== undefined) { 136 queryOpts.include_docs = options.include_docs; 137 } 138 if (options.reduce !== undefined) { 139 queryOpts.reduce = options.reduce; 140 } 141 if (options.group !== undefined) { 142 queryOpts.group = options.group; 143 if (options.group_level !== undefined) { 144 queryOpts.group_level = options.group_level; 145 } 135 146 } 136 147 … … 152 163 dfd.resolve( 153 164 array.map(result.rows, 154 function(result){ return result.value; })); 165 function(result){ 166 return [result.key, options.include_docs === true ? result.doc : result.value]; 167 })); 155 168 } 156 169 },function(err){ 157 170 dfd.reject(err); 158 171 }); 159 return QueryResults(dfd.promise);172 return CouchResults(dfd.promise); 160 173 } 161 174 }); 162 175 176 function CouchResults(results) { 177 if (!results) { 178 return results; 179 } 180 181 if(results.then){ 182 results = lang.delegate(results); 183 } 184 185 if (!results.forEach) { 186 results.forEach = function(callback) { 187 return Deferred.when(results, function(results) { 188 array.forEach(results, function(result) { 189 callback(result[1],result[0]); 190 }); 191 }); 192 } 193 } 194 195 return results; 196 } 197 163 198 return new CouchStore({target: 'data/rft/'}); 164 199
Note: See TracChangeset
for help on using the changeset viewer.