pinejs icon indicating copy to clipboard operation
pinejs copied to clipboard

Add support for upserts based on natural keys

Open thgreasi opened this issue 7 years ago • 2 comments

It would be great if we could do an upsert for a resource using its unique properties as a key. We are currently limited to POSTing and then PATCHing when erroring with a unique key constrain violation. For example, for a resource where <col1> & <col2> are a unique pair, we would want to make an upsert to insert or update a record containing a note, by sending a request containing <col1: X>, <col2: Y> and <note: Z>.

Additionally, it would be great to have these upserts work as part of batch operations as well.

See: https://github.com/resin-io/resin-api/issues/765

thgreasi avatar Feb 26 '18 08:02 thgreasi

This is available via PUT but it does set any non-specified fields back to defaults - I think there's value in a version that does not reset defaults as well

Page- avatar Sep 03 '20 09:09 Page-

Do the fields in the id field also have to be in the body of the POST @Page-? Maybe an example curl or pinejs-client one would be even better and good for future reference.

thgreasi avatar Sep 03 '20 10:09 thgreasi