Module

Yoga.Postgres.TypedQuery

Package
purescript-yoga-postgres
Repository
rowtype-yoga/purescript-yoga-postgres

#sqlParamToPGValue Source

sqlParamToPGValue :: SQLParameter -> PGValue

Convert a SQLParameter to a PG.PGValue

#executeSql Source

executeSql :: forall @params @result. HFoldlWithIndex TurnIntoSQLParam (Map String SQLParameter) (Record params) (Map String SQLParameter) => ReadForeign result => SQLQuery params -> Record params -> Connection -> Aff (Either String (Array result))

Execute a typed SQL query and parse results with yoga-json

Example: query = sql $ "SELECT * FROM users WHERE age > " ^ int @"minAge" ^ " AND name = " ^ str @"name" users <- executeSql @User query { minAge: 25, name: "Alice" } conn

#executeSqlRaw Source

executeSqlRaw :: forall @params. HFoldlWithIndex TurnIntoSQLParam (Map String SQLParameter) (Record params) (Map String SQLParameter) => SQLQuery params -> Record params -> Connection -> Aff QueryResult

Execute a typed SQL query with no result parsing (raw Foreign)

#executeSqlOne Source

executeSqlOne :: forall @params @result. HFoldlWithIndex TurnIntoSQLParam (Map String SQLParameter) (Record params) (Map String SQLParameter) => ReadForeign result => SQLQuery params -> Record params -> Connection -> Aff (Either String (Maybe result))

Execute a typed SQL query and return a single row

#executeMutation Source

executeMutation :: forall @params. HFoldlWithIndex TurnIntoSQLParam (Map String SQLParameter) (Record params) (Map String SQLParameter) => SQLQuery params -> Record params -> Connection -> Aff Int

Execute a mutation (INSERT/UPDATE/DELETE)