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

Method getEntity

packages/core/src/entity/Reference.ts:200–208  ·  view source on GitHub ↗

Returns the underlying entity, throwing an error if the reference is not initialized.

()

Source from the content-addressed store, hash-verified

198
199 /** Returns the underlying entity, throwing an error if the reference is not initialized. */
200 getEntity(): T {
201 if (!this.isInitialized()) {
202 throw new Error(
203 `Reference<${helper(this.entity).__meta.name}> ${helper(this.entity).getPrimaryKey()} not initialized`,
204 );
205 }
206
207 return this.entity;
208 }
209
210 /** Returns the value of a property on the underlying entity. Throws if the reference is not initialized. */
211 getProperty<K extends keyof T>(prop: K): T[K] {

Callers 2

getPropertyMethod · 0.95
loadPropertyMethod · 0.95

Calls 3

isInitializedMethod · 0.95
helperFunction · 0.85
getPrimaryKeyMethod · 0.65

Tested by

no test coverage detected