john-kelly / elm-postgrest

Make PostgREST requests in Elm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hardcode values

john-kelly opened this issue · comments

when the value does not come from the api.

similar to http://package.elm-lang.org/packages/NoRedInk/elm-decode-pipeline/3.0.0/Json-Decode-Pipeline#hardcoded

{-| -}
hardcoded : a -> Query uniq schema (a -> b) -> Query uniq schema b
hardcoded val (Query queryName schema params queryDecoder) =
    Query queryName
        schema
        params
        (apply queryDecoder (Decode.succeed val))

-- example

majorQuery =
    PG.query Resources.major Major
        |> PG.select .id
        |> PG.select .assist_id
        |> PG.select .title
        |> PG.select .description
        |> PG.select .school_id
        |> PG.hardcoded True

type alias Major =
    { id : Int
    , assist_id : String
    , title : String
    , description : Maybe String
    , school_id : Int
    , collapsed : Bool
    }