MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / Loadable

Function Loadable

packages/core/src/entity/BaseEntity.ts:273–287  ·  view source on GitHub ↗
(
  Base: TBase = EmptyBase as unknown as TBase,
)

Source from the content-addressed store, hash-verified

271 Base: EnsureNoLoadConflict<TBase> extends TBase ? TBase : never,
272): LoadableConstructor<TBase> & TBase;
273export function Loadable<TBase extends EntityConstructor>(
274 Base: TBase = EmptyBase as unknown as TBase,
275): LoadableConstructor<TBase> & TBase {
276 abstract class LoadableMixin extends Base {
277 async load(options?: LoadReferenceOptions<object>): Promise<object | null> {
278 return Reference.create(this).load(options) as Promise<object | null>;
279 }
280
281 async loadOrFail(options?: LoadReferenceOrFailOptions<object>): Promise<object> {
282 return Reference.create(this).loadOrFail(options) as Promise<object>;
283 }
284 }
285
286 return LoadableMixin as unknown as LoadableConstructor<TBase> & TBase;
287}
288
289const LoadableBaseEntityBase: LoadableConstructor<typeof BaseEntity> & typeof BaseEntity = Loadable(BaseEntity);
290

Callers 4

TagClass · 0.90
CategoryClass · 0.90
BaseEntity.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected