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.
43 lines (31 loc) • 849 B
text/typescript
import { Entity, MikroORM, PrimaryKey, Property } from '@mikro-orm/sqlite';
import { v4 as uuid } from 'uuid';
()
class A {
({ hidden: true })
_id!: number;
({ unique: true, length: 36 })
id: string = uuid();
()
name!: string;
constructor(name: string) {
this.name = name;
}
}
describe('GH issue 1444', () => {
let orm: MikroORM;
beforeAll(async () => {
orm = await MikroORM.init({
entities: [A],
dbName: `:memory:`,
});
await orm.schema.createSchema();
});
afterAll(() => orm.close(true));
test(`GH issue 1444`, async () => {
await orm.em.fork().persistAndFlush(new A('a1'));
const found1 = await orm.em.findOneOrFail(A, { name: 'a1' });
expect(typeof found1._id).toBe('number');
expect(typeof found1.id).toBe('string');
});
});