Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with PostgreSQL schemas #150

Open
filipgl opened this issue Jan 24, 2024 · 0 comments
Open

Working with PostgreSQL schemas #150

filipgl opened this issue Jan 24, 2024 · 0 comments

Comments

@filipgl
Copy link

filipgl commented Jan 24, 2024

Hello,

I would like to ask for help regarding the usage of PostgreSQL schemas. I have a sample database whose structure contains two additional schemas besides the default public schema. When I use the following code:

import Knex from "knex";
import schemaInspector from "knex-schema-inspector"

const database = Knex({
    client: "postgres",
    connection: {
        host: "localhost",
        port: 5432,
        user: "postgres",
        password: "1234",
        database: "example_eCommerce",
    },
});

const inspector = schemaInspector(database);

async function main(): Promise<void> {
    console.log(await inspector.tables())

    await database.destroy();
}

main();

Only tables of the public schema are printed. I know there is a withSchema method that can be used to set schema for inspector instance, but this approach is not very useful when schemas are unknown. Is there any way to get information about schemas of PostgreSQL database?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant