Module
Yoga.Postgres.TypedQuery
- Package
- purescript-yoga-postgres
- Repository
- rowtype-yoga/purescript-yoga-postgres
#sqlParamToPGValue Source
sqlParamToPGValue :: SQLParameter -> PGValueConvert 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 QueryResultExecute 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 IntExecute a mutation (INSERT/UPDATE/DELETE)