Skip to content

Instantly share code, notes, and snippets.

@dasch
Last active June 30, 2020 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasch/82a7729f6c64cf3bce0efec3530b73b0 to your computer and use it in GitHub Desktop.
Save dasch/82a7729f6c64cf3bce0efec3530b73b0 to your computer and use it in GitHub Desktop.
import Sql
import Sql.Param
findArticleById : Int -> Result Sql.Error Article
findArticleById id =
let
query =
"SELECT articles.id, articles.title, article.body WHERE articles.id = :id LIMIT 1"
in
Sql.queryWithParams query [ ("id", Sql.Param.int id) ]
|> Sql.first
module Sql.Decode exposing (..)
type Decoder a = ...
column : Decoder a -> String -> Decoder a
string : Decoder String
integer : Decoder Int
float : Decoder Float
bool : Decoder Bool
module Sql exposing (..)
type Query a = Query
{ decoder : Decoder a
, encoder : Encoder a
, query : String
, params : List (String, Param)
}
execute : Query a -> Result Error a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment