john-kelly / elm-postgrest

Make PostgREST requests in Elm
109 stars 14 forks source link

change filtering and ordering api #31

Closed john-kelly closed 7 years ago

john-kelly commented 7 years ago

reason being -- include is currently forced to be Maybe... because of the possibility of filtering the query

something like this.

sessionCmd =
    let
        speakerQuery =
            PG.query Resources.speaker Speaker
                |> PG.select .id
                |> PG.select .name
                |> PG.select .bio
    in
        PG.query Resources.session Session
            |> PG.select .id
            |> PG.select .location
            |> PG.select .start_time
            |> PG.include .speaker speakerQuery
            |> PG.list "http://postgrest.herokuapp.com/"
                [ .location |> PG.not PG.ilike "%russia%" ]
                [ PG.asc .start_time ]
                PG.noLimit
            |> Http.send Fetch

vs

sessionCmd =
    let
        speakerQuery =
            PG.query Resources.speaker Speaker
                |> PG.select .id
                |> PG.select .name
                |> PG.select .bio
    in
        PG.query Resources.session Session
            |> PG.select .id
            |> PG.select .location
            |> PG.select .start_time
            |> PG.include .speaker speakerQuery
            |> PG.list "http://postgrest.herokuapp.com/"
                { filter = [ .location |> PG.not PG.ilike "%russia%" ]
                , order = [ PG.asc .start_time ]
                , limit = PG.noLimit
                }
            |> Http.send Fetch
john-kelly commented 7 years ago

includeMany, paginate, first, list all need to be changed + we need to add includeNullable (with accompanying Phantom types)