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 {@link DbObject.commentData commentData} method.
const config = {
commentDataToken: "pg-structure"
}
// Assuming `[pg-structure]{ level: 3 }[/pg-structure]` is written in database table comment/description.
const someData = db.get("public.account").commentData; // { level: 3 }
Connection string to connect to the database e.g. postgres://user:password@host:5432/database
Database to connect. Default from environment var: PGDATABASE || DB_DATABASE
Environment variable prefix to get database client details. If no client configuration is provided pg-structure
tries to
get client details from environment variables to populate node-postgres
config (See ClientConfig of pg
).
All keys are built using this prefix in uppercase.
Environment Varibale | ClientConfig Key |
---|---|
DB_DATABASE | database |
DB_USER | user |
DB_PASSWORD | password |
DB_HOST | host |
DB_PORT | port |
DB_CONNECTION_STRING | connectionString |
DB_SSL | ssl |
... | ... |
const config = { envPrefix: "DB" }
List of the schemas or a pattern similar to SQL's LIKE
to select excluded schemas.
Character to separate {@link ForeignKey.sourceAlias source alias} and {@link ForeignKey.targetAlias target alias} in {@link ForeignKey foreign key} name.
Whether first part of the foreign key aliases contains target alias (i.e company_employees
) or source alias (i.e. employee_company
).
Database host. Default from environment var: PGHOST || DB_HOST
Whether to include PostgreSQL system schemas (i.e. pg_catalog
) from database.
Prevents pg-structure to close given database connection.
Name of the database. This is inferred if possible from client or connection string.
Database password. Default from environment var: PGPASSWORD || DB_PASSWORD
Database port. Default from environment var: PGPORT || DB_PORT
Optional module that exports functions to generate names for relationships. If not provided, default naming functions are used. All necessary information such as {@link Table table} names, {@link Column columns}, {@link ForeignKey foreign key}, {@link DbObject.commentData comment data} can be accessed via passed {@link Relation relation} parameter.
It is also possible to use one of the builtin naming functions: short
, optimal
or descriptive
.
const config = {
relationNameFunctions: "short",
}
const config = {
relationNameFunctions: "custom-module",
}
const config = {
relationNameFunctions: require.resolve("./my-module"),
}
const config = {
relationNameFunctions: {
o2m: (relation) => some_func(relation.foreignKey.name),
m2o: (relation) => some_func(relation.foreignKey.name),
m2m: (relation) => some_func(relation.foreignKey.name),
},
}
Passed directly to node.TLSSocket, supports all tls.connect options
Database username. Default from environment var: PGUSER || USER || DB_USER
Generated using TypeDoc
Either a node-postgres client or a configuration object or a connection string to create a node-postgres client.