If you're providing a web service that provides Add or Amend functionality for records in a database that has a unique key why would you not provide an "Insert or Update" method, in addition OR instead of two separate methods for Insert and Update?
I'd be grateful if anyone could suggest what benefit the two separate methods provides to the client?
Currently I'm focussed on the negative of forcing the client to have to hold state or to perform one request and then the other should it fail.
Having to store state, in my opinion, feels more prone to error.
答案 0 :(得分:1)
避免不必要的覆盖。
当您打算创建新记录但改写现有记录时,数据可能会丢失。
如果您在更新之前没有阅读记录,则将这两项操作分开是没有意义的。
这取决于你的情况。