Merge pull request #1020 from yunanbao/save_storage_bugfix

bugfix: save storage logic error
This commit is contained in:
sean1025 2019-04-26 09:51:33 +08:00 committed by GitHub
commit 7a9d5bab83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,16 +12,17 @@ module.exports = function storageCreator(id) {
},
setItem: async (name, value) => {
let inst = yapi.getInst(storageModel);
let data = await inst.get(id) || defaultData;
let curData = await inst.get(id);
let data = curData || defaultData;
let result;
data[name] = value;
if(!data){
if(!curData){
result = await inst.save(id, data, true)
}else{
result = await inst.save(id, data, false)
}
return result;
}
}
}
}