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.
32 lines (24 loc) • 671 B
text/typescript
import { Entity, PrimaryKey } from '@mikro-orm/core';
import { MikroORM, SqlEntityManager } from '@mikro-orm/sqlite';
()
class Author {
()
id!: number;
}
class MyEntityManager extends SqlEntityManager {
myCustomMethod(base: number): number {
return base * Math.random();
}
}
test('using custom EM class', async () => {
const orm = await MikroORM.init({
entities: [Author],
dbName: ':memory:',
entityManager: MyEntityManager,
});
await orm.schema.createSchema();
expect(orm.em).toBeInstanceOf(MyEntityManager);
const res = orm.em.myCustomMethod(123);
expect(typeof res).toBe('number');
await orm.close();
});