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

297
Views
TypeORM - One-To-Many relationship defined in EntitySchema

I'm using TypeORM with JS and it's docs are super minimal, so I couldn't find the solution for my question over there. I want to create a one-to-many bi-directional relationship and can't get over the following exception:

TypeORMError: Entity metadata for Team#groups was not found. Check if you specified a correct entity object and if it's connected in the connection options.

Thats the definition of the two entities (one team might have multiple groups):

module.exports = new EntitySchema({
  name: 'Team',
  tableName: 'team',
  columns: {
    id: {
      primary: true,
      type: 'uuid',
      generated: true,
    },
    name: {
      type: 'varchar',
    },
    
  },
  relations: {
    groups: {
      target: 'TeamGroups',
      type: 'one-to-many',
      inverseSide: 'team_id',
    },
  },
})
module.exports = new EntitySchema({
  name: 'TeamsGroups',
  tableName: 'team_group',
  columns: {
    team_id: {
      primary: true,
      type: 'uuid',
    },
    group_id: {
      primary: true,
      type: 'uuid',
    },
  },
  relations: {
    team_id: {
      target: 'Team',
      type: 'many-to-one',
      joinColumn: true,
    },
  },
})

What am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I can't test but I'm fairly sure it's this, looking at the error & docs:

module.exports = new EntitySchema({
  name: 'Team',
  tableName: 'team',
  columns: {
    id: {
      primary: true,
      type: 'uuid',
      generated: true,
    },
    name: {
      type: 'varchar',
    },
    
  },
  relations: {
    TeamGroups: {
      target: 'TeamGroups',
      type: 'one-to-many',
      inverseSide: 'team_id',
    },
  },
})
module.exports = new EntitySchema({
  name: 'TeamsGroups',
  tableName: 'team_group',
  columns: {
    team_id: {
      primary: true,
      type: 'uuid',
    },
    group_id: {
      primary: true,
      type: 'uuid',
    },
  },
  relations: {
    Team: {
      target: 'Team',
      type: 'many-to-one',
      joinColumn: true,
    },
  },
})
about 4 years ago · Juan Pablo Isaza Report
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!