bugfix: 修复 db allDocs、put 数据返回bug

This commit is contained in:
muwoo
2021-06-29 14:20:33 +08:00
parent 74f7f3ebdf
commit 0624be2d57
2 changed files with 35 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ export default {
}
saveData(dbPath, dbData);
return {
id: data.id,
id: data._id,
ok: true,
rev: '',
}
@@ -102,15 +102,23 @@ export default {
});
saveData(dbPath, dbData);
return docs.map(d => ({
id: d.id,
id: d._id,
success: true,
rev: '',
}))
},
allDocs({key}) {
const dbData = getData(dbPath);
const result = dbData.filter(d => d._id === key);
return result;
if (!key) {
return dbData;
}
if (typeof key === 'string') {
return dbData.filter(d => d._id.indexOf(key) >= 0);
}
if (Array.isArray(key)) {
return dbData.filter(d => key.indexOf(d._id) >= 0);
}
return [];
}
},