jrf0110 / dirac

A Node Postgres DB layer built with MoSQL
http://dirac.j0.hn
6 stars 2 forks source link

Add View Support #1

Closed jrf0110 closed 11 years ago

jrf0110 commented 11 years ago

Will be just like registering a table only we need to indicate that it's a view:

var dirac = require('dirac');

dirac.register({
  name: 'users_with_groups'
, type: 'view'
, query: {
    type: 'select'
  , table: 'users'
  , columns: ['*', 'array_agg( users_groups.group ) ) as groups']
  , joins: {
      users_groups: {
        type: 'left'
      , target: { id: '$users.id$' }
      }
    }
  }
});

dirac.users_with_groups.find( { id: { $in: [1,2,3,4,5,6] } }, function( error, users ){
  /* ... */
});