小编Ker*_*ren的帖子

TypeORM:[364] 错误:在字符 401 处缺少表“userorganisation”的 FROM 子句条目

在使用TypeORM和连接我为Postgres数据库设置的表时,我遇到了一个非常有趣的问题。我想通了,但我想我会在这里发布信息给其他有类似问题的人。

我在我的数据库上设置了 3 个表:user, organisation, user_organisation.

这样做的想法是,一个用户可以属于许多组织,而名为的表user_organisation将用户映射到这些组织。所以我的实体看起来像这样,

用户实体.ts

import { TimestampedEntity } from '@shared/entities/timestamped.entity';
import { Organisation } from '@user/entities/organisation.entity';
import { UserOrganisation } from '@user/entities/user-organisation.entity';
import { Column, Entity, Index, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
@Index(['email', 'password'])
export class User extends TimestampedEntity {
    @PrimaryGeneratedColumn()
    userId: number;

    @Column({
        length: 64
    })
    username: string;

    @Column({
        length: 500
    })
    email: string;

    @Column({
        length: 255
    })
    password: string;

    @Column({
        type: …
Run Code Online (Sandbox Code Playgroud)

postgresql typescript typeorm nestjs

7
推荐指数
1
解决办法
6995
查看次数

标签 统计

nestjs ×1

postgresql ×1

typeorm ×1

typescript ×1