vue-electron / vuex-electron

Integration of Vuex and Electron
MIT License
305 stars 96 forks source link

vuex-electron doesn't support batch deleting by condition from vuex-orm #52

Closed rassokhina-e closed 4 years ago

rassokhina-e commented 4 years ago

createSharedMutations doesn't allow to work with batch deleting method by condition from vuex-orm, which has the following form:

The issue with the loop of the method File.delete((file) =>... (with the condition) But other methods work well (insert, update, find, etc.). Also File.delete(id) without the condition works well.

In vuex-orm, both deleting by id and deleting by condition run the same mutation code. I cannot tell you why one works and the other doesn’t but I suspect it may be related to createSharedMutations. When I hide createSharedMutations() plugin (vuex-electron), the batch deleting method will work (I see the loop by the condition is starting work), but in vuex.json file won't be any changes.

the related link: https://github.com/vuex-orm/vuex-orm/issues/621

rassokhina-e commented 4 years ago

@truemelianenko Hello! What do you think about the issue above? Perhaps you can help me with that issue, please:)

rassokhina-e commented 4 years ago

Hello! I want to share with you the result of my research on combining vuex-orm and vuex-electron for the issue above. I've figured out that the method of batch deleting with condition works well in the Main process of Electron. So I moved that function to the main process:

ipcMain.on('deleteFiles', async function (event, ids) {
    await File.delete((file) => { return ids.includes(file.id) })
    event.sender.send('filesDeleted')
  }
})