Column

Kind: global class

new Column(args)

Constructor function. You don't need to call constructor manually. pg-structure handles this.

Returns: Column - - Column instance.

Param Type Description
args Object Attributes of the Column instance to be created.

column.allowNull : boolean

true if column is allowed to contain null values; otherwise false.

Kind: instance property of Column
Read only: true
See: notNull.

column.arrayDimension : number

Number of dimensions, if the column is an array type; otherwise 0.

Kind: instance property of Column
Read only: true

column.arrayType : string | null

If this column is an array, data type of the array. If column is not an array equals null.

Kind: instance property of Column
Read only: true

column.comment : string | null

Comment about column.

Kind: instance property of Column
Read only: true
See: Aliases description

column.commentData : Object

JS Object extracted from column description. Object is expected as JSON data between [JSON] and [/JSON] tags in description. Tags are case-insensitive.

Kind: instance property of Column
Read only: true
See: Aliases descriptionData
Example

let description = column.comment;            // -> 'This column holds name of account. [JSON]{ "extraData": 2 }[/PGEN]'
let extra = column.commentData;              // -> { extraData: 2 }
console.log(column.commentData.extraData);   // -> 2

column.db : Db

Db this table belongs to.

Kind: instance property of Column
Read only: true

column.default : string | null

Default value of the column without typecast. Default values includes single quotes except sql functions and numeric values.

Kind: instance property of Column
Read only: true
See: defaultWithTypeCast for default values with typecast as returned by PostgreSQL
Example

var column = db('crm').schema('public').table('contact').column('name');
var type = column.default;           // "'George'"
type = age.default;                  // 20
type = created_at.default;           // "now()"
type = column.defaultWithTypeCast;   // "'George'::character varying"

column.defaultWithTypeCast : string | null

Default expression of the column with typecast. PostgreSQL returns default values with typecast. Default values includes single quotes except sql functions and numeric values. Also sql functions and numeric values do not contain type cast.

Kind: instance property of Column
Read only: true
See: default for accessing default values without typecast.
Example

var column = db('crm').schema('public').table('contact').column('name');
var type = column.defaultWithTypeCast;   // "'George'::character varying"
type = age.defaultWithTypeCast;          // 20
type = created_at.defaultWithTypeCast;   // "now()"
type = column.default;                   // "'George'"

column.description : string | null

Comment about column.

Kind: instance property of Column
Read only: true
See: Aliases comment

column.descriptionData : Object

JS Object extracted from column description. Object is expected as JSON data between [JSON] and [/JSON] tags in description. Tags are case-insensitive.

Kind: instance property of Column
Read only: true
See: Aliases commentData
Example

let description = column.description;            // -> 'This column holds name of account. [JSON]{ "extraData": 2 }[/PGEN]'
let extra = column.descriptionData;              // -> { extraData: 2 }
console.log(column.descriptionData.extraData);   // -> 2

column.domainName : string | null

If column data type is a domain, this equals domain name without domain schema. Otherwise null.

Kind: instance property of Column
Read only: true
See: domainFullName domainFullCatalogName.
Example

var domainName = column.domainName; // i.e. 'phone_number'

column.domainFullName : string | null

If column data type is a domain, this equals domain name including domain schema. Otherwise null.

Kind: instance property of Column
Read only: true
See: domainName.
Example

var domainName = column.domainFullName; // i.e. 'public.phone_number'

column.domainFullCatalogName : string | null

If column data type is a domain, this equals domain name including domain schema. Otherwise null.

Kind: instance property of Column
Read only: true
See: domainName.
Example

var domainName = column.domainFullName; // i.e. 'public.phone_number'

column.domainSchema : string | null

If column data type is a domain, this equals domain schema name. Otherwise null.

Kind: instance property of Column
Read only: true
See: domainFullName.
Example

var domainName = column.domainSchema; // i.e. 'public'

column.enumLabels : Array.<string> | null

Array of the textual labels for enum values column may contain. If column is not an enum, then this equals undefined

Kind: instance property of Column
Read only: true
See: Aliases enumValues

column.enumValues : Array.<string> | null

Array of the textual labels for enum values column may contain. If column is not an enum, then this equals undefined

Kind: instance property of Column
Read only: true
See: Aliases enumLabels

column.foreignKeyConstraints : Map.<Constraint>

Map of foreign key constraints of the column, if column is part of one or more foreign key constraint.

Kind: instance property of Column
Read only: true

column.fullName : string

Full name of the Column with (.) notation.

Kind: instance property of Column
Read only: true
Example

var fullName = column.fullName; // public.account.id

column.fullCatalogName : string

Full name of the Column with (.) notation including catalog name.

Kind: instance property of Column
Read only: true
Example

var fullName = table.fullCatalogName; // crm.public.account.id

column.indexes : Map.<Index>

Map of indexes, which column is part of.

Kind: instance property of Column
Read only: true

column.isAutoIncrement : boolean

true if this column has an auto incremented (nextval()) default value or defined one of serial types.

Kind: instance property of Column
Read only: true
See: Aliases isSerial

column.isSerial : boolean

true if this column has an auto incremented (nextval()) default value or defined one of serial types.

Kind: instance property of Column
Read only: true
See: Aliases isAutoIncrement

column.isForeignKey : boolean

true if this column is a foreign key or part of a foreign key constraint; otherwise false. Please note that a foreign key may contain more than one column.

Kind: instance property of Column
Read only: true

column.isPrimaryKey : boolean

true if this column is a primary key or part of a primary key constraint; otherwise false. Please note that a primary key may contain more than one column.

Kind: instance property of Column
Read only: true

column.length : number | null

Length of the column. For data type identified as a character or bit string type, this is the declared maximum length. If column is an array, same rule applies data type of the array. For character arrays or bit string type arrays, this is the declared maximum length of the array's data type. For arrays atttypmod records type-specific data supplied at table creation time (for example, the maximum length of a varchar column). It is passed to type-specific input functions and length coercion functions. This value is undefined for all other data types or if no maximum length was declared.

Kind: instance property of Column
Read only: true

column.name : string

Name of the column.

Kind: instance property of Column
Read only: true

column.notNull : boolean

true if column is not allowed to contain null values; otherwise false.

Kind: instance property of Column
Read only: true
See: allowNull

column.parent : Table

Table this column belongs to.

Kind: instance property of Column
Read only: true
See: Aliases table
Example

var table = column.parent; // Table instance

column.precision : number | null

  • If data type identifies a numeric type, this contains the (declared or implicit) precision of the type for this column. The precision indicates the number of significant digits.
  • If data type identifies a date, time, timestamp, or interval type, this column contains the (declared or implicit) fractional seconds precision of the type for this attribute, that is, the number of decimal digits maintained following the decimal point in the seconds value.
  • If data type is an array. Same rules apply for the data type of the array, and this value would become precision of the data type of the array.
  • For all other data types, this is undefined.

Kind: instance property of Column
Read only: true

column.referencedColumns : Set.<Column>

All referenced columns in all foreign key constraints by this column.

Kind: instance property of Column
Read only: true

column.scale : number | null

  • If data type identifies an exact numeric type, this contains the (declared or implicit) scale of the type for this attribute. The scale indicates the number of significant digits to the right of the decimal point.
  • If data type is an array. Same rule applies for the data type of the array, and this value would become scale of the data type of the array.
  • For all other data types, this is undefined.

Kind: instance property of Column
Read only: true

column.schema : Schema

Schema this column belongs to.

Kind: instance property of Column
Read only: true

column.type : postgreSQLDataType

Data type of the column. For built-in types this is name of type. ARRAY, for arrays, and type of array can be found via arrayType. USER-DEFINED for user defined types, and type of it can be found via userDefinedType. For domain types this is not domain name, but underlying base type of that domain. Use domainName or domainFullName

Kind: instance property of Column
Read only: true
See

column.table : Table

Table this column belongs to.

Kind: instance property of Column
Read only: true
See: Aliases parent
Example

var table = column.table; // Table instance

column.userDefinedType : postgreSQLDataType | null

If type of column is user defined such as composite, enumerated, this is the data type of the underlying type.

Kind: instance property of Column
Read only: true

column.uniqueIndexesNoPk : Map.<Index>

Map of unique indexes, which column is part of. Excludes primary key indexes. PostgreSQL already creates a unique index for unique constraints. So there is no need to look for unique constraints which will result duplicates.

Kind: instance property of Column
Read only: true
See: uniqueIndexes for all unique indexes including primary key indexes.

column.uniqueIndexes : Map.<Index>

Map of unique indexes, which column is part of. PostgreSQL already creates a unique index for unique constraints. So there is no need to look for unique constraints which will result duplicates.

Kind: instance property of Column
Read only: true
See: uniqueIndexesNoPK for unique indexes excluding primary key indexes.