mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-31 14:50:26 +08:00
Merge pull request #1020 from yunanbao/save_storage_bugfix
bugfix: save storage logic error
This commit is contained in:
commit
7a9d5bab83
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user