Skip to content

Instantly share code, notes, and snippets.

@dasch
Last active Jun 30, 2020
Embed
What would you like to do?
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