In this guide, we'll walk through the process of creating internal table references in Xano based on matching external IDs across different data tables. This is particularly useful when importing or migrating data from external sources, where tables are connected through external IDs, and you want to establish internal references within Xano for seamless data integration.
Before we begin, ensure that you have the following:
Data Tables: Two or more data tables with matching external IDs across them. In our example, we'll use a "Company" table and a "Project" table, both containing an "external ID" field.
Table Reference: A table reference field in one of the tables, pointing to the table you want to create the internal reference to. In our case, we'll add a table reference field called "company ID" in the "Project" table, referencing the "Company" table.
companyRecords and projectRecords.const companyRecords = await query("Company", {});
const projectRecords = await query("Project", {});
Note: If you have a large number of records, consider implementing pagination to avoid querying all records at once.
projectRecords array.for (const project of projectRecords) {
// Loop logic goes here
}
const matchedCompany = companyRecords.find(
(company) => company.external_ID === project.external_ID
);
This will search through the companyRecords array and return the first object where the external_ID matches the external_ID of the current project record.
project record with the ID of the matched company record.await editRecord("Project", project.id, {
company_ID: matchedCompany.id,
});
This will update the "company ID" field in the "Project" table with the ID of the matching company record, effectively creating the internal table reference.
After completing the function setup, you can run the function to perform the internal data migration. All project records should now have the correct internal table reference to the associated company record.
You can verify the successful migration by navigating to the "Project" table and inspecting the "company ID" field values. Additionally, you can use the "Show Table References" feature in Xano to confirm that the "Project" and "Company" tables are properly linked.
By following these steps, you can easily migrate data from external sources and create internal table references within Xano, ensuring seamless data integration and relationships between your tables.
Join 100,000+ people already building with Xano.
Start today and scale to millions.
Start building for free