Commit 8b05e7b3 authored by qinhaitao's avatar qinhaitao

fix: 🐛 updateTasks bug

parent 30fbef5c
...@@ -501,10 +501,29 @@ export default class TaskService extends UserService { ...@@ -501,10 +501,29 @@ export default class TaskService extends UserService {
*/ */
async updateTasks(id: string, needUpdateKeysArray: object[], userInfo: IUserInfo): Promise<false | IUserInfo> { async updateTasks(id: string, needUpdateKeysArray: object[], userInfo: IUserInfo): Promise<false | IUserInfo> {
logger(needUpdateKeysArray) logger(needUpdateKeysArray)
const updateKeys: object = merge({}, ...needUpdateKeysArray) const updateKeys = merge({}, ...needUpdateKeysArray)
logger(updateKeys) logger(updateKeys)
const _$inc = updateKeys.$inc || {}
const _$set = updateKeys.$set || {}
const _$push = updateKeys.$push || {}
// 删除空的操作
if (!Object.keys(_$inc).length && updateKeys.$inc) {
delete updateKeys.$inc
}
if (!Object.keys(_$set).length && updateKeys.$set) {
delete updateKeys.$set
}
if (!Object.keys(_$push).length && updateKeys.$push) {
delete updateKeys.$push
}
if (!Object.keys(updateKeys).length) {
return userInfo
}
await this.updateUser(id, updateKeys) await this.updateUser(id, updateKeys)
return await this.getUserInfo() return await this.getUserInfo()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment