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

Method getPath

packages/sql/src/query/CriteriaNode.ts:136–156  ·  view source on GitHub ↗
(opts?: { addIndex?: boolean; parentPath?: string })

Source from the content-addressed store, hash-verified

134 }
135
136 getPath(opts?: { addIndex?: boolean; parentPath?: string }): string {
137 // use index on parent only if we are processing to-many relation
138 const addParentIndex =
139 this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
140 const parentPath =
141 opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName);
142 const index = opts?.addIndex && this.index != null ? `[${this.index}]` : '';
143 // ignore group operators to allow easier mapping (e.g. for orderBy)
144 const key =
145 this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key)
146 ? '.' + this.key
147 : '';
148 const ret = parentPath + index + key;
149
150 if (this.isPivotJoin()) {
151 // distinguish pivot table join from target entity join
152 return this.getPivotPath(ret);
153 }
154
155 return ret;
156 }
157
158 private isPivotJoin(): boolean {
159 if (!this.key || !this.prop) {

Callers 1

renameFieldToPKMethod · 0.95

Calls 5

isPivotJoinMethod · 0.95
getPivotPathMethod · 0.95
classNameMethod · 0.80
isKnownFragmentSymbolMethod · 0.80
getPathMethod · 0.65

Tested by

no test coverage detected