The metadata for Company#companyTypesLinks could not be located. Please verify that the entity object has been correctly specified

I am facing an issue with the relationship between my entities. I have tried everything, but I still encounter the same problem. Here are my scripts:

Company.entity.ts

export class Company extends AppBaseEntity {
  @Column('text', { name: 'nom', nullable: true })
  nom: string;
  @Column('varchar', { name: 'type_entite', length: 255, nullable: true })
  typeEntite?: CompanyEntityType;
  @Column('text', { name: 'note', nullable: true })
  note: string;

  @Column('varchar', { name: 'color', length: 15, nullable: true })
  color?: string;

  @Column('text', { name: 'textMailInvoices', nullable: true })
  textMailInvoices?: string;
  @Column('varchar', { name: 'subjectMailInvoices', length: 255, nullable: true })
  subjectMailInvoices?: string;
  @Column('tinyint', { name: 'archived', nullable: false, default: 0 })
  archived: boolean;

  @OneToMany(() => CompanyTypesLinks, companyTypesLink => companyTypesLink.company, { cascade: true, onUpdate: 'CASCADE' })
  public companyTypesLinks?: CompanyTypesLinks[];

and company-type-link.entity.ts

export class CompanyTypesLinks extends AppBaseEntity {
    @Column('varchar', { name: 'typesId', length: 36, nullable: true })
    typesId: string;

    @ManyToOne(() => Company, company => company.companyTypesLinks, { cascade: true })
    @JoinColumn({ name: 'companyId' })
    public company?: Company;

    @Column('varchar', { name: 'companyId', length: 36, nullable: true })
    companyId: string;

    @ManyToOne(() => CompanyTypes, companyTypes => companyTypes.companyTypesLinks)
    @JoinColumn({ name: 'typesId' })
    companyType?: CompanyTypes;

AppBaseEntity contains id

Answer №1

After some investigation, I discovered the solution by updating my file named company-type-link - it turns out that the correct file name should have been:

company-type-link.entity.ts

The issue was that the term "entity" was missing from the original file name.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the issue with the variable appearing as undefined in

My class has a property: public requestLoadPersonal: Personal[] = []; As well as a method: private filterByGender(selectedValue: any): void { console.log(this.requestLoadPersonal); this.requestLoadPersonal = this.requestLoadPersonal.filter( ...

Error message: The types in React Redux typescript are incompatible and cannot be assigned to each other

I recently converted my React App to TypeScript and encountered an error that I'm having trouble understanding. Any help would be greatly appreciated. Here is the code for my "mapStateToProps" function: function mapStateToProps(state: AppState): MapS ...

No solution was found for implementing Airbnb TypeScript in React.js (Next.js) using ESLint

screenshot I encountered an issue where I couldn't locate the Airbnb typescript option in React JS (Next JS) within ESLint. Prior to this, I had installed Storybook and mistakenly clicked "yes" when prompted to migrate ESLint to Storybook. ...

What is causing unexpected behavior when one service calls another service?

Let's say I make a call to a service that returns an observable, and if it doesn't encounter any errors, then another service should be called which also returns an observable. What I tried doing is calling both services separately, one after th ...

Pass an array of objects to an Angular 8 component for rendering

Recently, I started working with Angular 8 and faced an issue while trying to pass an array of objects to my component for displaying it in the UI. parent-component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: ...

What is the best way to declare a TypeScript type with a repetitive structure?

My data type is structured in the following format: type Location=`${number},${number};${number},${number};...` I am wondering if there is a utility type similar to Repeat<T> that can simplify this for me. For example, could I achieve the same resul ...

Removing spaces within brackets on dynamic properties for objects can be achieved by utilizing various methods such as

I've encountered an issue with my code that involves getting spaces within square brackets for the dynamic properties of an object. Even after searching through Code Style/Typescript/Spaces, I couldn't find any settings to adjust this. Could thes ...

React with TypeScript: The struggle of getting LocalStorage to work

Currently, I am dealing with persistence in a todo application developed using React and TypeScript. To achieve the desired persistence, I have implemented localStorage. Allow me to share some code snippets: const [todos, setTodos] = useState<todoMod ...

What is the best way to handle asynchronous actions while initializing a database in Next.js?

My goal is to create tables during the database initialization stage with a structure like this: CREATE TABLE IF NOT EXISTS users ( "id" SERIAL PRIMARY KEY, "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "name&quo ...

Change number-type object fields to string representation

I am in the process of creating a function that takes an object as input and converts all number fields within that object to strings. My goal is for TypeScript to accurately infer the resulting object's fields and types, while also handling nested st ...

Exploring the directories: bundles, lib, lib-esm, and iife

As some libraries/frameworks prepare the application for publishing, they create a specific folder structure within the 'dist' directory including folders such as 'bundles', 'lib', 'lib-esm', and 'iife'. T ...

Issue with React Context Provider failing to set value

I am currently diving into React context hooks and encountering an issue that is puzzling me. I have established a user context with the simple string message of "hello user" as follows: import { useContext, createContext } from "react" export ...

Exploring unit tests: Customizing an NGRX selector generated by entityAdapter.getSelectors()

Let's imagine a scenario where our application includes a books page. We are utilizing the following technologies: Angular, NGRX, jest. To provide some context, here are a few lines of code: The interfaces for the state of the books page: export int ...

Error encountered during the production build of Angular 2. No issues reported during development phase

During development, I can successfully run the code below. However, when I deploy to production, I encounter the following errors: node_modules/@angular/common/src/pipes/async_pipe.d.ts(39,38): error TS2304: Cannot find name 'Promise'. node_modu ...

Utilizing multiple page objects within a single method in Cypress JS

I have been grappling with the concept of utilizing multiple page objects within a single method. I haven't been able to come up with a suitable approach for implementing this logic. For instance, consider the following methods in my page object named ...

Troubleshooting the TS2559 error when using radium in React typescript: CSSProperties type mismatch

Looking to integrate Typescript into React and incorporate some styling using Radium. I understand that JSX style does not support media queries, but I'm unsure how to resolve this issue. Can anyone provide guidance? Thank you! Encountering errors w ...

Issue encountered while attempting to differentiate 'object Object'. NgFor only permits arrays and iterables

Having a JSON file containing a list of properties for sale, I am attempting to utilize *NgFor to iterate through the data and generate a list. Being relatively new to Angular and app development, there's a possibility that I might have misunderstood ...

Can the TypeScript Event class be customized and extended?

Snippet of Code: class CustomEvent extends Event { constructor(name) { super(name); } } var customEvent = new CustomEvent("scroll"); Error Encountered During Runtime: An error occurred: Uncaught TypeError: Failed to construct 'Ev ...

Submit information by utilizing' content-type': 'application/x-www-form-urlencoded' and 'key': 'key'

Attempting to send data to the server with a content-type of 'application/xwww-form-urlencode' is resulting in a failure due to the content type being changed to application/json. var headers= { 'content-type': 'applica ...

How to fix the TS4090 error regarding conflicting definitions for a node in Visual Studio 2017

My TypeScript project is building and running, but I'm encountering a multitude of build errors all originating from one issue: TS4090: (TS) Conflicting definitions for 'node' found at 'C:/[projectpath]/node_modules/@types/node/index ...