bugfix: save storage logic error

This commit is contained in:
zhanglu 2019-04-26 09:02:12 +08:00
parent ff1de09e73
commit 3434beb22a

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;
}
}
}
}