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.

40 lines (31 loc) 786 B
import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/better-sqlite'; @Entity() class Author { @PrimaryKey() id!: number; @Property({ unique: true }) name!: string; } let orm: MikroORM; beforeAll(async () => { orm = MikroORM.initSync({ entities: [Author], dbName: ':memory:', }); await orm.schema.createSchema(); }); afterAll(async () => { await orm.close(true); }); test(`GH issue 2973`, async () => { for (const i of [1, 2, 3]) { for (const name of ['John', 'Bob']) { await orm.em.transactional(async em => { const foo1 = await em.findOne(Author, { name }); foo1 && await em.removeAndFlush(foo1); const foo2 = em.create(Author, { name }); await em.persistAndFlush(foo2); }); } } });