# pg-structure

# Type aliases

# BuiltinRelationNameFunction

Ƭ BuiltinRelationNameFunction: "short" | "descriptive"

Defined in types/index.ts:50

# CollisionsByTable

Ƭ CollisionsByTable: object

Defined in types/index.ts:76

# Type declaration:

# M2MWithout

Ƭ M2MWithout: "any" | "source" | "join" | "target"

Defined in pg-structure/relation/m2m-relation.ts:13

# RelationNameCollision

Ƭ RelationNameCollision: object

Defined in types/index.ts:55

# Type declaration:

  • [ relationName: string]: string[]

# RelationNameFunction

Ƭ RelationNameFunction: function

Defined in types/index.ts:45

# Type declaration:

▸ (relation: Relation): string


Name Type
relation Relation

# RelationWithout

Ƭ RelationWithout: "any" | "source" | "target"

Defined in pg-structure/base/relation.ts:14

# TypeCategory

Ƭ TypeCategory: "A" | "B" | "C" | "D" | "E" | "G" | "I" | "N" | "P" | "R" | "S" | "T" | "U" | "V" | "X"

Defined in types/index.ts:34

# Variables

# Const packageJson

packageJson: any = JSON.parse(readFileSync(join(__dirname, "../../package.json"), { encoding: "utf8" }))

Defined in pg-structure/db.ts:16

# readFile

readFile: readFile

Defined in util/helper.ts:15

# Functions

# deserialize

deserialize(serializedData: string): Db

Defined in index.ts:411


Name Type Description
serializedData string is serialized data of the Db object.

Returns: Db

Db object for given serialized data.

# getRelationNameFunction

getRelationNameFunction(relationNameFunction: RelationNameFunction | BuiltinRelationNameFunction): RelationNameFunction

Defined in util/naming-function/index.ts:11


Name Type
relationNameFunction RelationNameFunction | BuiltinRelationNameFunction

Returns: RelationNameFunction

# pgStructure

pgStructure(pgClientOrConfig: Client | ClientConfig | string, __namedParameters: object): Promise‹Db

Defined in index.ts:357


pgClientOrConfig: Client | ClientConfig | string

Default value __namedParameters: object= {}

Name Type Default Description
commentDataToken string "pg-structure" is tag name to extract JSON data from from database object's comments. For example by default JSON data between [pg-structure][/pg-structure] is available imn database objects. Data can be retrieved with commentData method.
excludeSchemas undefined | string | string[] - is pattern similar to SQL LIKE (i.e public_%) or list of schemas to exclude.
foreignKeyAliasSeparator string "," is character to separate {@link ForeignKey.sourceAlias source alias} and {@link ForeignKey.targetAlias target alias} in foreign key name. For example: prime_color,product.
foreignKeyAliasTargetFirst boolean false is whether first part of the foreign key aliases contains target alias (i.e company_employees) or source alias (i.e. employee_company).
includeSchemas undefined | string | string[] - is pattern similar to SQL LIKE (i.e public_%) or list of schemas to include.
includeSystemSchemas undefined | false | true - is whether to include PostgreSQL system schemas (i.e. pg_catalog) from database.
name undefined | string - is name of the database. This is inferred if possible from client or connection string.
relationNameFunction function | "short" | "descriptive" "short" Optional function to generate names for relationships. If not provided, default naming functions are used. All necessary information such as table names, columns, foreign key, comment data can be accessed via passed relation parameter. * It is also possible to use one of the builtin naming functions such as short, descriptive.

Returns: Promise‹Db

Db object which represents given database's structure.