serializing object vs Not to
I have learn't one thing about serializing object when dealing with retrieving objects from the database. When you want to use the object accross platform like phones and native application, serializing objects in retrieveData() function becomes portent, it will serve you heck of the time in future when you decide to use mobile apps to access data. Apps made in ionic cordova will not connect straight to the database but will use an api end point to access the data. So, what happens is that, a web application will have a web service ( Mainly a page communicating with the database ) that retrieves the data from database and seriolizes the objects into Json objects for easy access accross platforms.
[NB] Take note that this route is not secure as anything in the web browser can be hacked or accessed. How does someone access data in the browser? you ask. Someone can see all the data passed from your database into the browser mainly by going to developer's mode from the browser's settings and play with the attributes from the console. Lets say, you did not want the user to see all the data that comes from the data base, only selected data, if all data from database is passed to the browser it will be seen.