In this comprehensive guide, we'll walk you through the process of setting up a seamless integration between your Bubble and Xano databases. This integration will allow you to maintain a synchronized relationship between the two platforms, ensuring consistent and up-to-date data across your applications.
Before we begin, make sure you have the following:
In the first part of this tutorial, we set up a basic synchronization between the Bubble and Xano databases, ingesting all records from the Bubble API response. If you haven't completed this step, refer to the previous guide on setting up the initial data ingestion.
In this section, we'll focus on setting up and maintaining relationships between the Bubble and Xano databases. We'll cover how to handle company and deal relationships, as well as deal with pagination to ensure all records are synchronized.
First, let's identify the existing relationships in your Bubble database. In our example, we have a company relationship and a deal relationship associated with the customers table.
Inside the Xano customers table, we have corresponding table relationships set up with company_id and deal_id fields.
To maintain these relationships in Xano, we'll use conditional checks to verify if a relationship exists before adding or updating records. Here's how we'll do it:
for each loop that iterates over the customers records.get filter to check if the company relationship exists for the current customer record.company relationship exists (doesn't equal null), add the record to the companies table in Xano using the add or edit record step.company record from the output.deal relationship, adding records to the deals table in Xano.By following this approach, we ensure that relationships are only created or updated in Xano if they exist in the Bubble data.
To handle pagination and ensure all records are synchronized, we'll use a while loop instead of a for each loop. Here's how it works:
pagination_continue variable and set it to true.cursor_count variable and initialize it to 0.while loop that continues running as long as pagination_continue is true.while loop, include the logic for adding customer records and handling relationships (from the previous steps).cursor_count by the number of records processed (e.g., 100).cursor_count parameter to fetch the next set of records.remaining_record_count from the API response is 0. If so, set pagination_continue to false to stop the loop.By implementing this pagination logic, you'll be able to fetch and process all records from the Bubble API, regardless of the total number of records.
In some cases, you may have a list of relationships associated with a record. In our example, we have a list_of_deals relationship in the Bubble data. To handle this, follow these steps:
list_of_deals exists and is not null for the current customer record.list_of_deals and perform the following for each deal:deals table in Xano using the add or edit record step.deals table.deals_list field in the customers table.By following these steps, you'll ensure that the list of relationships is properly maintained in the Xano database.
Now that we've set up the logic for synchronizing data between Bubble and Xano, it's time to automate the process using Xano's task feature.
Once enabled, the task will run according to the specified schedule, keeping your Bubble and Xano databases synchronized.
Congratulations! You've successfully set up a seamless integration between your Bubble and Xano databases, maintaining relationships and ensuring consistent data across both platforms. This integration will streamline your development process and provide a solid foundation for building robust applications.
Remember, if you encounter any issues or have suggestions for improvement, feel free to leave a comment or reach out to the community for support. Happy coding!
Join 100,000+ people already building with Xano.
Start today and scale to millions.
Start building for free