Random assigned id to db.
Name of database.
SQL query results returned from database to build pg-structure.
const schemaArray = db.schemas;
const isAvailable = db.schemas.has('another_schema');
const public = db.schemas.get('public');
const name = public.name;
const names = db.schemas.map(schema => schema.name);
Version of the PostgreSQL Engine
All types of the database including system types and entities.
Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named type. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All entities of the database. Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named entity. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All entities of the database. Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named entity. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All indexes of the database. Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named index. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
Name collisions of table relations if there are any, otherwise undefined.
All system types of the database. Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named type. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All tables of the database. Returned array have all objects, you may loop over them.
However Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named table. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All user defined types of the database excluding entities such as
table, {@link Views view}, materialized view and sequence types.
Entities are also composite types in PostgreSQL. To get all types including entities use typesIncludingEntities
method.
Returned array have all objects, you may loop over them.
However two PostgreSQL schemas may have same named type. get
method of
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
All user defined types of the database including entities such as
table, {@link Views view}, materialized view and sequence types.
Entities are also composite types in PostgreSQL. To get all types excluding entities use types
method.
{@link IndexableArray https://www.npmjs.com/package/indexable-array} returns first one.
You may also use getAll
or get(1234, { key: oid })
.
Returns schema, table or column for given path. Path should be in dot (.) notation.
If no schema is provided looks into public
schema as PostgreSQL does.
Note for TypeScript users: Since get()
could return one of the many possible types, you may need to specify your expected type using as
.
i.e. const result = db.get("public") as Schema
;
const schema = db.get('public'); // Returns public schema.
const table = db.get('public.contact'); // Returns contact table in public schema.
const table2 = db.get('contact'); // Returns contact table in public schema.
const column = db.get('public.contact.name'); // Returns name column of the contact table in public schema.
const column2 = db.get('contact.name'); // Returns name column of the contact table in public schema.
is the path of the requested item in dot (.) notation such as public.contact
requested database object.
Serializes object.
CAVEATS:
pg-structure
. (Even between minor versions are not guaranteed).relationNameFunctions
args, if it is not a module name.
import pgStructure, { deserialize } from "pg-structure";
const db = await pgStructure({ database: "db", user: "u", password: "pass" });
const serialized = db.serialize();
const otherDb = deserialize(serialized);
Generated using TypeDoc
Class which represent a database. Provides attributes and methods for details of the database.