MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / getManyToManyJoinTable

Function getManyToManyJoinTable

packages/orm/src/client/query-utils.ts:319–342  ·  view source on GitHub ↗
(
    schema: SchemaDef,
    joinTableName: string,
)

Source from the content-addressed store, hash-verified

317 * See issue #2715.
318 */
319export function getManyToManyJoinTable(
320 schema: SchemaDef,
321 joinTableName: string,
322): ManyToManyJoinTableEndpoints | undefined {
323 const cache = getSchemaLookupCache(schema);
324 if (!cache.m2mJoinTable) {
325 const map = new Map<string, ManyToManyJoinTableEndpoints>();
326 for (const model of Object.values(schema.models)) {
327 for (const field of Object.values(model.fields)) {
328 const m2m = getManyToManyRelation(schema, model.name, field.name);
329 if (m2m?.joinTable && !map.has(m2m.joinTable)) {
330 map.set(m2m.joinTable, {
331 model: model.name,
332 field: field.name,
333 otherModel: m2m.otherModel,
334 otherField: m2m.otherField,
335 });
336 }
337 }
338 }
339 cache.m2mJoinTable = map;
340 }
341 return cache.m2mJoinTable.get(joinTableName);
342}
343
344function computeManyToManyRelation(schema: SchemaDef, model: string, field: string) {
345 const fieldDef = requireField(schema, model, field);

Callers

nothing calls this directly

Calls 2

getSchemaLookupCacheFunction · 0.85
getManyToManyRelationFunction · 0.85

Tested by

no test coverage detected