CodeIgniter Forums
Where does a data-import map go? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Where does a data-import map go? (/showthread.php?tid=86775)



Where does a data-import map go? - evansharp - 02-16-2023

Hello,
I'm writing an application that will need to import a complex dataset in JSON format (via file upload) to a database. A human will have to perform a step of mapping JSON keys to DB fields because the data structure is variable. 
What is the best approach for organizing the code for these operations? I have already a controller that manages the upload; where should it go from there? Before being passed to a model for db saving, where should the pre and post human processing take place? A library? A service? Private methods of the upload controller?
Thanks,
Evan


RE: Where does a data-import map go? - InsiteFX - 02-17-2023

Create a Library Class for the methods and a service to load the Library Class.


RE: Where does a data-import map go? - evansharp - 02-21-2023

Just what I was looking for, thank you!