GithubHelp home page GithubHelp logo

pg-schema's Introduction

pg-schema

Type provider from PostgreSQL. With some batteries.

The aid of this package is to make productive type-safe access to PostgreSQL database. Look at Tutorial

Brief

In compile time system information is getting from DB: tables, keys (private, unique, foreign), types (including arrays and enumerations). All information is moved to Type Level. I.e. you can write any statically-checked functions. E.g. there is a static guarantees that all db-field could be convert to haskell-field.

There are two ways of generation this info:

  • file generation (recommended). It can be done in project's Setup.hs. In this case on each compilation db will checked and info will be regenerated if there are some changes (checking is very fast). If db is not available you will use file which was generated before
  • TH (obsolete + convenient for demonstration)

For data selection you can create regular haskell records with field names corresponding db-names (like in aeson). Besides that you can use fields with name of FK-constraints (from or to root table). Some small instances are generated for data-record by TH and then you can populate it with data without writing sql at all. It allows to get json-like data tree in one request (really, it is one SELECT to DB). On each level of tree you can set safe conditions (where, order by, limit/offset) using small EDSL.

All of this with static guarantees.

DML (Insert/Update/Delete) should be done later.

pg-schema's People

Contributors

odr avatar lagunoff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.