MCPcopy Create free account
hub / github.com/apitable/apitable / findNextLookUpField

Function findNextLookUpField

packages/widget-sdk/src/subscribe/datasheet_map.ts:62–86  ·  view source on GitHub ↗
(field: ILookUpField, fieldMap: IFieldMap, visitedField?: Set<string>)

Source from the content-addressed store, hash-verified

60 let index = 1;
61
62 const findNextLookUpField = (field: ILookUpField, fieldMap: IFieldMap, visitedField?: Set<string>) => {
63 const _visitedField = visitedField || new Set();
64 if (_visitedField.has(field.id)) {
65 return;
66 }
67 _visitedField.add(field.id);
68 // The actual fields of this table lookup query.
69 const lookUpTargetField = (Field.bindModel(field) as LookUpField).getLookUpTargetField();
70 if (!lookUpTargetField) {
71 // The foreign key data for this table is not loaded.
72 const foreignField = fieldMap[field.property.relatedLinkFieldId] as ILinkField;
73 if (foreignField && (foreignField.type === FieldType.Link || foreignField.type === FieldType.OneWayLink)) {
74 console.log(`2.${index}.1 "${field.name}" the data of the queried table (${foreignField.property.foreignDatasheetId}) is not loaded`);
75 linkLookUpField(foreignField.property.foreignDatasheetId, _visitedDst);
76 }
77 } else {
78 console.log(`2.${index}.1 "${field.name}" the actual field of the query is: 「${lookUpTargetField.name}」`, { lookUpTargetField });
79 }
80 // lookup lookup le lookup
81 // The lookup of this table looks up another lookup field of the foreign key table.
82 if (lookUpTargetField && lookUpTargetField.type === FieldType.LookUp) {
83 console.log(`2.${index}.2 "${lookUpTargetField.name}" is also a lookup field`);
84 findNextLookUpField(lookUpTargetField, fieldMap, _visitedField);
85 }
86 };
87
88 for (const field of lookUpFields) {
89 findNextLookUpField(field, fieldMap);

Callers 1

linkLookUpFieldFunction · 0.85

Calls 6

linkLookUpFieldFunction · 0.85
getLookUpTargetFieldMethod · 0.80
hasMethod · 0.65
addMethod · 0.65
bindModelMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected