I have this typeorm entity:
@Entity({ name: 'trans' })
export class Transaction {
@PrimaryGeneratedColumn({ type: 'int', name: 'trans_id' })
id: number;
@OneToOne(type => Credit, credit => credit.transaction, { cascade: true })
credit: Credit
}
With the following relation:
@Entity({ name: 'trans_credit' })
export class Credit {
@PrimaryColumn({ type: 'int', name: 'trans_id' })
id: number;
@OneToOne(type => Transaction, transaction => transaction.credit)
@JoinColumn({ name: 'trans_id' })
transaction: Transaction;
}
There is no FK defined on the trans_credit table. Corresponding tables are:
CREATE TABLE `trans` (`trans_id` int(10) unsigned NOT NULL AUTO_INCREMENT) AUTO_INCREMENT=1
CREATE TABLE `trans_credit` (`trans_id` int(10) unsigned NOT NULL)
All entities and table declarations presented here are simplified of course.
When I try to query:
const fromEntity = getRepository(Transaction).find({
where: [
{ status: 'pending', credit: { j5: 1 } }
]
});
I get this:
Error: Relation with property path trans_id in entity was not found
Why oh why is this happening?