undeexcepturi
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
35 lines (25 loc) • 917 B
text/typescript
import { Entity, OneToOne, PrimaryKey, Property, Rel } from '@mikro-orm/core';
import { MikroORM } from '@mikro-orm/postgresql';
export class Profile {
id!: number;
rating!: Rel<Rating>;
}
export class Rating {
profile!: Profile;
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
rating: number = 1000;
}
test('validation of FK as PK being the owning side', async () => {
await expect(MikroORM.init({
entities: [Profile, Rating],
dbName: `mikro_orm_test_gh_3869`,
metadataCache: { enabled: false },
connect: false,
})).rejects.toThrow(`Rating.profile cannot be primary key as it is defined as inverse side. Maybe you should swap the use of 'inversedBy' and 'mappedBy'.`);
});