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.
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 }
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 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
).
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.
Optional module that exports functions 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: 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),
},
}
Generated using TypeDoc
Options for the
pgStructure
.