-
Notifications
You must be signed in to change notification settings - Fork 2
DbRelation
do- edited this page Mar 30, 2025
·
20 revisions
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:
Name | Type | Description |
---|---|---|
columns |
{String: DbColumn / null } Object / function |
data columns definitions, may be set as a function called with the DbRelation instance available as this
|
columnsToDrop |
[String] | Calculated list of columns with null definition, presumed to be dropped if found existing |
pk |
[String ] |
the list of column names composing the primary key |
keys |
{String: DbIndex} Object | index definitions |
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 undefinedpk
; - for each element of
pk
, setsnullable: false
for the eponymous column, or throws an Error if it's not found.