Commit e6a50e62 authored by Tristan Cavelier's avatar Tristan Cavelier

add include_docs option management

parent 0d397a26
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
}; };
// XXX doc string // XXX doc string
IndexedDBStorage.prototype.getList = function () { IndexedDBStorage.prototype.getList = function (option) {
var rows = [], onCancel, open_req = indexedDB.open(this._database_name); var rows = [], onCancel, open_req = indexedDB.open(this._database_name);
return new Promise(function (resolve, reject, notify) { return new Promise(function (resolve, reject, notify) {
open_req.onerror = function () { open_req.onerror = function () {
...@@ -388,11 +388,18 @@ ...@@ -388,11 +388,18 @@
var cursor = index_req.result, now; var cursor = index_req.result, now;
if (cursor) { if (cursor) {
// Called for each matching record. // Called for each matching record.
if (option.include_docs) {
rows.push({ rows.push({
"id": cursor.value._id, "id": cursor.value._id,
"doc": cursor.value, "doc": cursor.value,
"value": {} "value": {}
}); });
} else {
rows.push({
"id": cursor.value._id,
"value": {}
});
}
now = Date.now(); now = Date.now();
if (date <= now - 1000) { if (date <= now - 1000) {
notify({"loaded": rows.length}); notify({"loaded": rows.length});
...@@ -421,7 +428,7 @@ ...@@ -421,7 +428,7 @@
IndexedDBStorage.prototype.allDocs = function (command, param, option) { IndexedDBStorage.prototype.allDocs = function (command, param, option) {
/*jslint unparam: true */ /*jslint unparam: true */
this.createDBIfNecessary(). this.createDBIfNecessary().
then(this.getList.bind(this)). then(this.getList.bind(this, option)).
then(command.success, command.error, command.notify); then(command.success, command.error, command.notify);
}; };
......
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