UNPKG

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.

27 lines (18 loc) 543 B
import { Entity, Ref, ManyToOne, MikroORM, PrimaryKey, Property } from '@mikro-orm/sqlite'; class A { @PrimaryKey() id!: number; @Property({ type: 'string' }) test!: string; } @Entity() class B { @ManyToOne({ entity: () => A, primary: true, ref: true }) a!: Ref<A>; } test('validates missing @Entity() decorator', async () => { await expect(MikroORM.init({ entities: [B], dbName: ':memory:', })).rejects.toThrow('B.a targets abstract entity A. Maybe you forgot to put @Entity() decorator on the A class?'); });