'How to move data from Coredata to Firestore in iOS?

I am working on an iOS app in which i have to send data from my coreData to the Firestore. I want to implement following features.

  1. Fetching user's data from coreData including each table's attributes and relationships.
  2. Sending fetched data to the Firestore.

I am using DFS algorithm to parse the attributes and relationships, creating JSON of each record and then sending it to firestore.

My question is:

is it a right approach or i am doing it in a wrong way.

Suggestions are highly appreciable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source