0.2.0 • Published 8 years ago

chaingres v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

chaingres

Postgres: Unchained. Use cascading style programming to structure your Postgres queries.

By Chris Cates :star:

Email hello@chriscates.ca :mailbox:

Installation

npm install chaingres --save

Usage

Here is a sample demo to use chaingres:

var chaingres = require("./chaingres");
var postgres  = require("pg");
var queryConn = "postgres://"+name+":"+password+"@"+host+":"+port+"/"+db+"";

    client    = new pg.Client(queryConn);


//Example INSERT
chaingres
  .new(client)
  .insert({
    "column1": "value1",
    "column2": "value2"
  }).then(function(err,result) {
    console.log(result);
  })

//Example SELECT
chaingres
  .new(client)
  .select(["c1", "c2"])
  .from("table")
  .join({
    "table": "table2",
    "on": [{
      "column": "tableId",
      "op": "=",
      "fromTable": "table",
      "fromColumn": "id"
    }]
  })
  .order({
    "table": "table2",
    "column": "id",
    "order": "ASC"
  })
  .limit(10)
  .offset(0)
  .then(function(err,result) {
    //This will return a bunch of rows
    console.log(result);
  })
0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago