Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cocreature/postgresql-named

Deserialize PostgreSQL rows to Haskell records by matching column names and record field names
https://github.com/cocreature/postgresql-named

haskell postgresql

Last synced: 3 months ago
JSON representation

Deserialize PostgreSQL rows to Haskell records by matching column names and record field names

Awesome Lists containing this project

README

        

# postgresql-named

[![Travis](https://img.shields.io/travis/cocreature/postgresql-named.svg)](https://travis-ci.org/cocreature/postgresql-named)
[![Hackage](https://img.shields.io/hackage/v/postgresql-named.svg)](https://hackage.haskell.org/package/postgresql-named)

Library for deserializing rows in `postgresql-simple` (or any other
library that uses `FromRow`) based on column names instead of the
positions of columns.

## Example

```haskell
{-# LANGUAGE DeriveGeneric #-}
import Database.PostgreSQL.Simple.FromRow
import Database.PostgreSQL.Simple.FromRow.Named
import qualified GHC.Generics as GHC
import Generics.SOP

data Foobar = Foobar
{ foo :: !String
, bar :: !Int
} deriving (Show, Eq, Ord, GHC.Generic)

instance Generic Foobar

instance HasDatatypeInfo Foobar

instance FromRow Foobar where
fromRow = gFromRow
```