DbView - do-/node-doix-db GitHub Wiki

DbView is a DbRelation descendant describing a SQL view.

As for all DbObject's descendants, instances of this class should only be created by calling DbSchema's create method (normally, in the course of adding).

Properties

See DbObject's Properties

See DbRelation's Properties

Name Type Description Notes
sql String The effective SQL query source Part of CREATE VIEW after AS
rawSql String The original SQL query source Normally, equals sql, but the latter may be adjusted (see wrap)
wrap Boolean If true, rawSql is replaced with SELECT ${columns} FROM (${rawSql}) Ensures the column list consistency when SELECT * is in use, but may impact performance, so false by default
specification String Part of CREATE VIEW between the view name and AS May contain a custom column list (unrelated to columns) and some vendor specific options
options String SQL code to place between CREATE and VIEW RECURSIVE and so on.
queue Object see DbQueue

Sample description

// module.exports = 
{

    label: 'Some view',

    columns: {
        id: 'int    // PK',
    },
    
    pk: 'id',

  /* CREATE */

//  options: 'RECURSIVE',

  /* VIEW ${name} */

//  specification: '(id)',

  /* AS */

    sql: 'SELECT 1 AS id' // + ' WITH CHECK OPTION',

    queue: {
        order:      'ts DESC',
        rq:         {type: 'some_notifications', action: 'process'},
//      maxPending: 1,                      // default: no concurrency
//      lag:        [0, 10, 1000, Infinity] // example: slow down on errors, stop on 3rd in a row
//      maxLatency: 10000,                  // execution time limit
//      on:         {start: function () {...this...}, ...}, 
//      globals:    ...,
//      generators: ...,
    },

}