Batch Update for Relationships

Hi All, I am importing a huge chunk of data from our SQL Server to our iPads for our sales reps to have archived data when they are in areas without cell service. I can bring in the data via JSON with ease. The problem I am running into is how to create the relationship between two entities efficiently as there are thousands of records.

For example, I have two entities: Order and OrderLine

  • Order has a one-to-many relationship with OrderLine called lines.
  • OrderLine has the inverse called order.
  • Both entities have a common key called orderKey.

Using For loops on the Order entity and then filtering the OrderLine and adding them to the Order is way too slow. I am hoping that there is a way to do a batch update on the relationship or what would be the best way to match up the data in the two entities.

I'm using Swift 5.5

Thanks in advance!

Batch Update for Relationships
 
 
Q