john-kelly / elm-postgrest

Make PostgREST requests in Elm
109 stars 14 forks source link

add support for bulk UPSERT with POST and single UPSERT with PUT #58

Open john-kelly opened 6 years ago

john-kelly commented 6 years ago

https://github.com/PostgREST/postgrest/issues/256

john-kelly commented 5 years ago

something like this:

createOrUpdateOne :
    Schema id attributes
    ->
        { change : Changeset attributes
        , select : Selection attributes a
        , where_ : Condition attributes
        }
    -> Request a

createOrUpdateMany :
    Schema id attributes
    ->
        { change : List (Changeset attributes)
        , select : Selection attributes a
        , order : List (Order attributes)
        , limit : Maybe Int
        , offset : Maybe Int
        }
    -> Request (List a)

need to consider option for duplicate resolution:

  1. Prefer: resolution=ignore-duplicates
  2. Prefer: resolution=merge-duplicates

something like:

type Duplicates = Ignore | Merge

or... just a boolean , mergeDuplicates: Bool.