Assume, I have an event creation page with some form fields in UI. And I have a smart contract to store the event in events mapping or the public array in some struct format.
event public events;
mapping(uint=>event) public events;
I'm submitting the UI and data is stored in the contract.
I have a list events page, which will display all the events created in the contract.
After searching many forums, I got some info, can someone validate this.
For every submits or save in contract, an event is called and UI is having the watcher and stored in the local storage and displays in the UI. The events data can be a mapping or array here.
I don't want to have any intermediate storage for the application, so whenever the UI refresh the event watcher will receive all the state data and again update the local storage and display in the UI.
For event submit new event object is created and pushed into the events array.
And writing the get events method, to iterate the events array and returns the list of string elements for each key in the object and then again concatenating and destructure the strings in an array of objects in UI to bind with the UI.
I think the computation for the second approach will be high because of the iteration. Since we are developing the Dapp I don't want to have any intermediate database again which become as a centralised system.
Can someone explain the various possibilities of storing and retrieving data from the smart contract which is a preferable way so far.
It will help me a lot. Thanks in advance.