現在、APIを作成しており、
postmanでAPIを叩くと次のエラーが発生します。
"Entity metadata for OrganizationEntity#project was not found. Check if you specified a correct entity object and if it's connected in the connection options
テーブル構造は、
projectsデーブルの中にorganization(組織ID)がある。といった感じになっています。
リレーションを確認しても間違いに気づけないのでどなたかアドバイスをいただけないでしょうか?
よろしくお願いします。
//project.t import { Entity, CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn, OneToMany, ManyToOne, JoinColumn, Column, BaseEntity, } from "typeorm"; import OrganizationEntity from "../organization/organization"; @Entity({ name: "PROJECTS" }) export default class ProjectEntity extends BaseEntity { // bigint maps to string, is converted back to number in mapper @PrimaryGeneratedColumn({ type: "bigint", name: "id" }) public id!: number; @ManyToOne(() => OrganizationEntity, (organization) => organization.project) @JoinColumn({ name: "organization_id" }) public organization!: OrganizationEntity; @CreateDateColumn({ type: "timestamp", name: "created_at" }) public created_at!: string; @UpdateDateColumn({ type: "timestamp", name: "updated_at" }) public updated_at!: string; }
//organization.ts import { Entity, CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn, OneToMany, JoinColumn, Column, BaseEntity, } from "typeorm"; import ProjectEntity from "../project/project"; @Entity({ name: "ORGANIZATIONS" }) export default class OrganizationEntity extends BaseEntity { // bigint maps to string, is converted back to number in mapper @PrimaryGeneratedColumn({ type: "bigint", name: "id" }) public id!: number; @Column({ type: "varchar", length: 50 }) public name!: string; @OneToMany(() => ProjectEntity, (project) => project.organization) @JoinColumn({ name: "organization_id", }) public project!: ProjectEntity[]; @CreateDateColumn({ type: "timestamp", name: "created_at" }) public created_at!: string; @UpdateDateColumn({ type: "timestamp", name: "updated_at" }) public updated_at!: string; }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。