Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
How to change TypeORM's insert to junction table?

There is the junction table defined this way:

    @ManyToMany(() => Table2)
    @JoinTable({
        name: 'table1_link_table2',
        joinColumns: [
            {
                name: 'table1_id',
                referencedColumnName: 'id',
            },
        ],
        inverseJoinColumns: [
            {
                name: 'table2_id',
                referencedColumnName: 'id',
            },
            {
                name: 'version',
                referencedColumnName: 'version',
            },
        ],
    })
    table2instances: Table2[];

And in migration there is added one more column, let's say it's cost.

How can I change queries, that are generated to insert in table1_link_table2?

TypeORM generates queries like: INSERT INTO "test_link_question"("table1_id", "table2_id", "version") VALUES ($1, $2, $3);

But I need it to be INSERT INTO "test_link_question"("table1_id", "table2_id", "version", "cost") VALUES ($1, $2, $3, $4); and cost to be taken from Table1. Is it possible?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!