我正在存储一个JSON对象,其中在IndexedDB中包含18张图像-每个图像最大为50KB,但是以某种方式在indexedDB中需要118 MB? -我不知道为什么这么重?
除了图像,全部都是纯JSON,主要是带有文本的键/值对...
请参阅附件的屏幕截图
我正在使用DexieJS来处理IndexedDB
正在保存到数据库的函数如下:
export const savePendingSurvey = (id, currentSurvey, surveyAnswers, surveyFiles) => {
const updatedSurvey = {
id: id,
createdAt: new Date(),
status: 'UNSUBMITTED',
surveyVersion: currentSurvey.survey.version,
currentSurvey: {
...currentSurvey.survey
},
currentSurveyAnswers: [
...surveyAnswers
],
currentSurveyFiles: [
...surveyFiles
]
};
db.open().then(() => {
db.pendingSurveys.put(updatedSurvey).then((response) => {
console.log('done adding pending survey', response);
}).then(() => {
return db.pendingSurveys.toArray();
}).then((data) => {
console.log('pendings surveys in db', data);
}).catch((e) => {
if ((e.name === 'QuotaExceededError') ||
(e.inner && e.inner.name === 'QuotaExceededError')) {
// QuotaExceededError may occur as the inner error of an AbortError
alert('QuotaExceeded error! - There are not enough space available on your device');
} else {
// Any other error
console.error(e);
}
});
});
};
[似乎每次我对对象进行最简单的更新,即使更改了简单的文本,每次都会在项目之间添加100-300kbs:/