Type to store relation name collisions by tables.
{
'public.contact': {
m2o: [],
o2m: [
{
carts: [
'[public.contact]――― cart_contact ――⥷ [public.cart]',
'[public.contact]――― other_cart_contact ――⥷ [other_schema.cart]'
]
}
],
m2m: []
}
}
Parallel safety of the PostgreSQL function.
Type to store a relation name collision. Keys are relation names and values are information about relations with that name.
Type for functions to generate names for relations. All necessary information such as table names, columns, foreign key, comment data can be accessed via passed relation parameter.
const config = {
relationNameFunctions: {
o2m: (relation) => some_function(relation.targetTable.name),
m2o: (relation) => some_function(relation.targetTable.name),
m2m: (relation) => some_function(relation.targetTable.name),
},
}
In which session_replication_role modes the trigger fires.
Event that fires the trigger
whether the trigger fires once for each processed row or once for each statement.
Time at which the trigger fires
PostgreSQL system-defined values of typcategory. See pg_type in PostgreSQL docs.
Volatility of the PostgreSQL function.
Reverse engineers a PostgreSQL database and creates Db instance which represents given database's structure. There are several options such as to include or exclude schemas, provide custom names to relations. Please refer to Options for detailed explanations.
IMPORTANT: Please note that if included schemas contain references to a non-included schema, this function throws exception. (e.g. a foreign key to another schema or a type in another schema which is not included)
const db = await pgStructure({ database: "db", user: "u", password: "pass" }, { includeSchemas: ["public"] });
is either a node-postgres client or a configuration object or a connection string to create a node-postgres client.
are preferences to modify reverse engineering process.
Db object which represents given database's structure.
Reads configuration details from environment variables to create node-postgres client.
Keys are upper case environment variables prefixed with options.envPrefix
(default is DB
).
Environment Varibale | ClientConfig Key |
---|---|
DB_DATABASE | database |
DB_USER | user |
DB_PASSWORD | password |
... | ... |
const db = await pgStructure({ includeSchemas: ["public"] });
const db = await pgStructure(); // Read connection details from environmet variables.
are preferences to modify reverse engineering process.
Db object which represents given database's structure.
Deserializes given data to create Db object. Please note that custom relation name functions are not serialized.
To serialize, provide functions as a module and use them with { relationNameFunctions: "my-module" }
.
import pgStructure, { deserialize } from "pg-structure";
const db = await pgStructure({ database: "db", user: "u", password: "pass" });
const serialized = db.serialize();
const otherDb = deserialize(serialized);
is serialized data of the Db
object.
Db object for given serialized data.
Generated using TypeDoc
Modes of the PostgreSQL function arguments.