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

DbRelation is a DbObject descendant describing a database table like object: a named collection of strictly structured records good to mention in the FROM clause of a SELECT SQL statement, such as:

Properties

See DbObject's Properties

Name Type Description
columns {String: DbColumn} Object data columns definitions
pk [String] the list of column names composing the primary key
keys {String: DbIndex} Object index definitions

Constructor

This class is considered abstract, so the constructor

new DbRelation ({name, columns, pk})

should never be called explicitly.

In the base implementation, it:

  • copies all properties from the given argument to this;
  • builds DbColumn instances for columns from incoming plain Objects or Strings (parsing DSL);
  • if pk came scalar, wraps it into an Array, empty Array for null or undefined pk;
  • for each element of pk, sets nullable: false for the eponymous column, or throws an Error if it's not found.