Skip to content

Conversation

@jrf0110
Copy link
Owner

@jrf0110 jrf0110 commented Jun 7, 2016

Easily composable factory based API:

var db = require('dirac')('postgres://localhost:5432/my_db?ssl=true');

// More specific
var db = require('dirac')
  .host('localhost')
  .port(5432)
  .ssl(true)
  .db('my_db');

// Use middleware for instance
db = require('dirac')('...')
  .use( db.relationships() )
  .use( myCustomMiddlewares );

// Query by strings
db.query('select * from users where id = $1', [10])
  .then( function( results ){
    // Promised based API or node-style callbacks
  });


db.query({
  type: 'select'
, table: 'users'
, where: { id: 10 }
}).then(...);

// Setup dals
db.users = db.dal({ ... });

// Initiate query objects
var query = db.users.find()
  .where({ id: 10 })
  .or({ id: 12 })
  .one({ table: 'region' })
  .many({ table: 'orders' })

query.exec().then( ... );

@jrf0110
Copy link
Owner Author

jrf0110 commented Apr 2, 2015

Arbitrary query composition:

var q1 = dirac.query();

q1.table('orders')
  .where({ status: 'submitted' })
  .order(['id desc'])
  .limit(30);

db.users.find()
  .where.({ id: 10 })
  .many( q1 )

dirac.query() would simply return a fancy mosql object with setters/getters. If it's just called from the base dirac namespace, no connection string or middleware will be associated to it

@jrf0110
Copy link
Owner Author

jrf0110 commented Apr 24, 2015

Place a bigger emphasis on the Relationships helpers

@jrf0110 jrf0110 mentioned this pull request Apr 24, 2015
@jrf0110
Copy link
Owner Author

jrf0110 commented Dec 9, 2015

Stream support with https://github.com/brianc/node-pg-query-stream

db.orders().find()
  .where({ ... })
  .many({ table: 'order_items', alias: 'items' })
  .pipe( res );

Where .pipe would automatically execute the query with a streaming client.

@jrf0110 jrf0110 changed the title v1.0.0 Wishlist v1.0.0 Release Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants