How to effectively Sync Multiple Entities from Local to Database
Question
Application Type
Mobile

Hi Guys,

I am facing an issue with one of my implementations. 

Currently i have 5 DB Entities which are tightly coupled as parent child relationship. Now i will have one to many of each level.

For Example

Entity - Country have multiple States

States have multiple Districts

Districts have multiple Local Bodies etc

Now for better performance, what i did was to create a replica of these entities into my Local Storage and the user will be adding details and saving them. Once the user is done with all the changes, he Submits the Form and in the background, i have created a Client action which will manually create an entry in database recursively for each entry in the Local Storage.

This was working fine, but now when i test it in a larger scale, i mean when i increased the number of internal loops, the flow starts to break and the Client action timesout in between since there are too many Server actions happening in a loop.

I know this is a poor architecture, but i couldnt figure out a better way, as i thought of using Sync action, but since there is too much of loops in each layer of Parent Child entries, i dont know if Sync can do its job right. I cant use a Server action, since i need to fetch data from local store for each entry in parent in loop.

Can someone please help me with a better way to implement this requirement

Thanks

Hi LearnIT,

Please refer the below link.

https://www.outsystems.com/forums/discussion/60306/best-way-to-get-db-data-on-mobile-app/

Thanks & Kind Regards,

Sachin


Hi Sachin,

This page is not accessible

Thanks

For me even it is not working when directly clicked the link. So, please try to copy and paste the URL into the browser directly and it will work.

In the documentation pages you will find a handful of Offline Data Syncing Patterns for optimizing common use cases. According to your specific scenario, you might be particularly interested in the Read/Write Data One-To-Many pattern, as it deals with the common Parent-Child relationships, but if make sure to also check the read-only patterns if they better fit your use case.

Just take in mind that depending on your specific needs and the amount and nature of the data you are handling, even these patterns might not be enough to keep your Server Actions from timing out, so you might want to look at strategies for dividing the synchronization logic into smaller chunks or by expanding the default Timeout of your Server Actions if really necessary.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.