(
schema: SchemaDef,
joinTableName: string,
)
| 317 | * See issue #2715. |
| 318 | */ |
| 319 | export 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 | |
| 344 | function computeManyToManyRelation(schema: SchemaDef, model: string, field: string) { |
| 345 | const fieldDef = requireField(schema, model, field); |
nothing calls this directly
no test coverage detected