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

Multi column keys. #47

Open
ozum opened this issue May 3, 2020 · 0 comments
Open

Multi column keys. #47

ozum opened this issue May 3, 2020 · 0 comments

Comments

@ozum
Copy link

ozum commented May 3, 2020

Hi,

I need many to many relations in PostGraphile, and found this plugin but multi column key relations are not generated. I see // TODO: handle multi-column comment.

pg-structure (I'm developer of it) library provides the functions you need.

Below is a sample code for this use case:

const pgStructure = require( "pg-structure").default;

async function demo() {
  const db = await pgStructure({ database: "teknik", user: "user", password: "password" }, { includeSchemas: ["public", "Region"] });
  const accountTable = db.get("public.Account"); // TypeScript: db.get("public.Account") as Entity
  console.log(accountTable.belongsToManyTables.map(t => t.name))
  console.log(accountTable.m2mRelations.map(r => r.name))
}

demo();

You can access all many to many tables including multi column keys using belongsToManyTables and m2mRelations. I suggest to use m2mRelations object, which provides more info and possibilities. You can use your inflection methods easily.

I would be happy to if you have questions or need assistance how to use.

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