Commit 5b97a6a9 authored by Tristan Cavelier's avatar Tristan Cavelier

localstorage.js allDocs method redesigned

parent 974cac47
...@@ -206,45 +206,19 @@ var newLocalStorage = function (spec, my) { ...@@ -206,45 +206,19 @@ var newLocalStorage = function (spec, my) {
}; };
/** /**
* get all filenames belonging to a user from the document index * Get all filenames belonging to a user from the document index
* @method allDocs * @method allDocs
* @param {object} command The JIO command * @param {object} command The JIO command
*
* Available options:
* - {boolean} conflicts Add a conflicts object to the response
* - {boolean} revs Add the revisions history of the document
* - {boolean} revs_info Add revisions informations
* - {boolean} include_docs Include documents with index
*/ */
that._allDocs = function (command) { that.allDocs = function (command) {
setTimeout(function () { setTimeout(function () {
var new_array = [], that.error({
array = priv.getFileNameArray(), "status": 405,
i,l, "statusText": "Method Not Allowed",
path = 'jio/local/'+priv.username+'/'+priv.applicationname, "error": "method_not_allowed",
include_docs = command.getOption('include_docs'), "message": "Your are not allowed to use this command",
doc, item; "reason": "LocalStorage forbids AllDocs command executions"
for (i = 0, l = array.length; i < l; i += 1) {
item = array[i];
if (include_docs === true){
doc = that._get(path+'/'+item.id+'/'+item.value.key );
new_array.push({
"id":item.id,
"key":item.key,
"value":item.value,
"doc":doc
});
} else {
new_array.push({
"id":item.id,
"key":item.key,
"value":item.value
}); });
}
}
that.success ({total_rows:new_array.length,rows:new_array});
}); });
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment