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

Method create

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

Creates a Reference wrapper for the given entity, preserving identity if one already exists.

(entity: T | Ref<T>)

Source from the content-addressed store, hash-verified

53
54 /** Creates a Reference wrapper for the given entity, preserving identity if one already exists. */
55 static create<T extends object>(entity: T | Ref<T>): Ref<T> {
56 const unwrapped = Reference.unwrapReference(entity);
57 const ref = helper(entity).toReference() as Reference<T>;
58
59 if (unwrapped !== ref.unwrap()) {
60 ref.set(unwrapped);
61 }
62
63 return ref as Ref<T>;
64 }
65
66 /** Creates a Reference wrapper for an entity identified by its primary key, wrapped in a Ref. */
67 static createFromPK<T extends object>(

Callers

nothing calls this directly

Calls 5

helperFunction · 0.85
unwrapReferenceMethod · 0.80
toReferenceMethod · 0.65
setMethod · 0.65
unwrapMethod · 0.45

Tested by

no test coverage detected