Haskell Tutorials
latest
Opaleye Tutorials
Instant Gratification
Basic DB mappings
Advanced DB Mappings
Selecting rows
Inserting rows
Updating rows
Reflex Tutorials
Webapp Framework
Haskell Tutorials
Docs
»
Opaleye Tutorials
Edit on GitHub
Opaleye Tutorials
ΒΆ
Contents:
Instant Gratification
Overview
Preliminaries
Teaching your table schema to Opaleye
Connecting to the Postgresql database
Selecting all rows
Inserting a row
Updating a row
Selecting a single row
Basic DB mappings
Overview
Creating the DB
Strange polymorphic records
Different types for read & write
Handling
NULL
and database defaults
Different types for read & write - again
Wrapping-up
Template Haskell expansion
Advanced DB Mappings
Overview
SQL for table creation
Code that we’ll run through
Core mechanism for mapping custom Haskell types to PG types
Newtypes for primary keys
Mapping ENUMs to Haskell ADTs
Handing Postgres Arrays
Handling JSONB
Making columns read-only
Selecting rows
Inserting rows
SQL for table creation
Inserting rows
Getting the ID of a newly inserted row
Three functions missing from the Opaleye API
Dealing with errors
Using a different record-type for INSERTs
Updating rows
SQL for table creation
Updating rows
Getting the updated rows back from the DB
Commentary on Opaleye’s update APIs
Multi-table updates (updates with JOINs)