Open shaunmulligan opened 8 years ago
I wonder how to correctly deal with deletion failures in any of the devices.
For example, consider we have devices aaaa
, bbbb
and cccc
. We trigger a batch deletion as:
resin.models.device.remove([ 'aaaa', 'bbbb', 'cccc' ])
But bbbb
fails. Would you expect the promise to be rejected?
I can think of the following approaches:
Option 3 looks reasonable to me.
In my usecase I made it reject unless all of them deleted successfully, but its definitely not the correct approach. What are the implications of rejecting the whole promise, is there a way an error can be returned indicating which devices weren't successfully deleted?
I wonder whether it would be better to just provide examples of doing this via something like Promise.map([ 'aaaa', 'bbbb', 'cccc' ], resin.models.device.remove)
?
@Page- Are there any advantages on doing a batch removal with a single pine request?
It will be quicker, and will also be all or nothing
Ah nice, so I guess we can rely on pine being smart enough to remove all or nothing.
would be cool if functions like
resin.models.device.remove()
could take an array of uuids as an argument. It would make batch deleting and other actions much easier :smile: