On Tue, Jun 10, 2014 at 3:11 AM, Andrew Hacking <[email protected]> wrote:
> A fairly common pattern in a JSON API based server is to support > idempotent insert/update (aka upsert). It is especially useful when using > client assigned v4 UUIDs as PUT can be used for both create and update. > > I noticed a ruby gem https://github.com/seamusabshere/upsert that > provides an efficient way to do upsert, however I would rather stick to > using Sequel than introduce another dependency. > > Sequel for me has been a performance and functionality win over the other > ruby alternatives, adding upsert is something that would yield performance > additional wins. > > Is there any interest in implementing an upset operation in sequel? > > Hi, it might be a common pattern but I would say IMHO it's a bad practice from a pure API point of view: - You're supposed to return 201 or 204 status codes: 201 if item is created, 204 if item is updated. - If you use the gem you mentioned, hiding whether it's a true insert or a true update, how would you generate the right status code? - This gem does not generate such status codes by the way. More reading on this here: https://www.salesforce.com/us/developer/docs/api_rest/Content/dome_upsert.htm Furthermore, the gem you mentioned is not generic enough: it only support few backends. Sequel on the other hand is generic. -- Christian -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
