Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/cocreature/postgresql-named
- Owner: cocreature
- License: bsd-3-clause
- Created: 2017-06-12T18:19:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-19T17:20:20.000Z (almost 7 years ago)
- Last Synced: 2024-09-29T17:41:58.751Z (3 months ago)
- Topics: haskell, postgresql
- Language: Haskell
- Homepage:
- Size: 16.6 KB
- Stars: 13
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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.SOPdata Foobar = Foobar
{ foo :: !String
, bar :: !Int
} deriving (Show, Eq, Ord, GHC.Generic)instance Generic Foobar
instance HasDatatypeInfo Foobar
instance FromRow Foobar where
fromRow = gFromRow
```