Skip to content

Multi column keys. #47

Open
Open
@ozum

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions