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.

41 lines (29 loc) 715 B
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'; import { MikroORM } from '@mikro-orm/postgresql'; enum GreatEnum { EnumValue = 'enumValue', AnotherEnumValue = 'anotherEnumValue' } @Entity() class MyEntity { @PrimaryKey() id!: number; @Property({ type: 'json', default: '[]' }) greatProp: GreatEnum[] = []; } let orm: MikroORM; beforeAll(async () => { orm = await MikroORM.init({ dbName: 'gh4555', entities: [MyEntity], }); await orm.schema.refreshDatabase(); }); afterAll(async () => { await orm.close(true); }); it('4555', async () => { const root = new MyEntity(); root.greatProp = [GreatEnum.AnotherEnumValue]; await orm.em.persistAndFlush(root); });