Cannot read property 'ownerColumns' of undefined
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
Problems listed below. Trying to save this causes the issue mentioned in the title
// Report.ts
import {BaseEntity, Column, Entity, Index, ManyToMany, PrimaryGeneratedColumn} from 'typeorm';
import ReportCategoryEnum from '../ReportCategory';
import User from './User';
@Entity('Report')
export default class Report extends BaseEntity {
@PrimaryGeneratedColumn()
public Id: number;
@ManyToMany(type => User)
public Reporter: User;
@Column() @Index('category', ['Category'])
public Category: ReportCategoryEnum;
@Column({type: 'text'})
public Reason: string;
@Column({type: 'bigint'}) @Index('guild', ['GuildId'])
public GuildId?: string;
@Column({type: 'simple-array'})
public MessageIds: string[] = [];
@Column({type: 'simple-array'})
public Links: string[];
@ManyToMany(type => User)
public ReportedUsers: User[];
@ManyToMany(type => User)
public ConfirmationUsers: User[];
@Column({type: 'datetime'}) @Index('insert_date', ['InsertDate'])
public InsertDate: Date = new Date;
@Column({type: 'datetime'}) @Index('update_date', ['UpdateDate'])
public UpdateDate: Date = new Date;
}
// User.ts
import {BaseEntity, Column, Entity, Index, ManyToMany, PrimaryColumn, PrimaryGeneratedColumn, Table} from 'typeorm';
import Report from './Report';
@Entity('User')
export default class User extends BaseEntity {
@Column({type: 'bigint'}) @Index('user_id', ['UserId'])
@PrimaryColumn()
public Id: string;
@Column({type: 'datetime'}) @Index('insert_date', ['InsertDate'])
public InsertDate: Date = new Date;
constructor(id: string) {
super();
this.Id = id;
}
}
// Code calling this
const report = new Report();
report.Reporter = await repo.findOne(body.Reporter) || new User(body.Reporter);
report.Category = body.Category;
report.Reason = body.Reason;
report.GuildId = body.GuildId;
const promises: Promise<any>[] = [];
for (const x of body.ReportedUsers) {
const user = await repo.findOne(x) || new User(x);
if (!report.ReportedUsers) {
report.ReportedUsers = [];
}
report.ReportedUsers.push(user);
promises.push(user.save())
}
await Promise.all([...promises, report.save()]);
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (8 by maintainers)
Top Results From Across the Web
TypeORM: Cannot read property 'getParameters' of undefined
I think "Cannot read property 'getParameters' of undefined" means it can't find the metadata of the particular table (Entity class). Please read ...
Read more >cannot read properties of undefined (reading 'owncolumns')
Hi everyone, I'm using @storybook/vue to make my storybook and I'm trying to embed a view component in my mdx files but I...
Read more >typeorm/typeorm - Gitter
3. Do I need to update ? _. TypeError: Cannot read property 'name' of undefined.
Read more >Cannot read property 'column' of undefined - DataTables
Cannot read property 'column' of undefined ... This is very random so I can't find out what the issue is. When serverside true...
Read more >EntityMetadata | typeorm
Original user-given table name (taken from schema or @Entity(tableName) decorator). If user haven't specified a table name this property will be undefined.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I guess its because you have missed
@JoinTabledecorator on yourManyToManyrelations.YW.
Answering people questions takes time and lot of efforts. Contribute to the future of TypeORM and support the project!