Type

Class which represent a custom PostgreSQL type. Provides attributes and methods for details of the type.

Kind: global class

new Type(args)

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

Param Type Description
args Object Attributes of the Type instance to be created.
args.parent Schema Parent Schema of the Type.
args.name string Name of the Type.
args.description string Description of the Type.

type.name : string

Name of the type.

Kind: instance property of Type
Read only: true

type.fullName : string

Full name of the Type.

Kind: instance property of Type
Read only: true
Example

var fullName = type.fullName; // public

type.fullCatalogName : string

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

Kind: instance property of Type
Read only: true
Example

var fullCatalogName = schema.fullCatalogName; // crm.public

type.schema : Schema

Schema this type belongs to.

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

var schema = type.schema; // Schema instance

type.parent : Db

Db this schema belongs to.

Kind: instance property of Type
Read only: true
See: Aliases schema
Example

var db = type.parent; // Schema instance

type.db : Db

Db this type belongs to.

Kind: instance property of Type
Read only: true

type.comment : string

Comment of the type.

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

type.description : string

Comment of the schema.

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

type.columns : Map.<Column>

All Column instances in the type as a Map. They are ordered same order as they are defined in database type.

Kind: instance property of Type
Read only: true
See: Map
Example

var isAvailable  = type.columns.has('foo');
var column       = type.columns.get('user_id');
var name         = column.name;

for (let column of type.columns.values()) {
    console.log(column.name);
}

for (let [name, column] of type.columns) {
    console.log(name, column.name);
}

type.get(path) ⇒ Column | undefined

Returns Column on given path relative to Type.

Kind: instance method of Type
Returns: Column | undefined - - Requested item.

Param Type Description
path string Path of the requested item in dot (.) notation such as 'public.contact'

Example

var column = type.get('contact'),      // Returns contact column of the type.