UNPKG

expeditavoluptas

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.

19 lines (13 loc) 483 B
import type { AnyEntity } from '@mikro-orm/core'; import { Collection, ReferenceType, wrap } from '@mikro-orm/core'; export abstract class BaseEntity22 { abstract id: number; constructor() { const props = wrap(this, true).__meta.properties; Object.keys(props).forEach(prop => { if ([ReferenceType.ONE_TO_MANY, ReferenceType.MANY_TO_MANY].includes(props[prop].reference)) { (this as any)[prop] = new Collection(this as AnyEntity); } }); } }