Hello, friends!
Recently I posted some questions about problems that I am facing on this my project, but answers are not fully adjusted on our needs and it can’t fully fix our problems.
I decided to go through details, explain my current state and get some more help from you guys.
So, we are making Dapp where you have crystals, fanatics, weapons.
All information, normally, is parsed though events. We are parsing those event tables and making another table from it (using afterSave).
Recently, we had to update code on moralis and for 1 minute server was down. In that 1 minute, our testers got new weapons and fanatics.
When server turned on, the information within 1 minute was in sync table, but afterSave did not work for last events and our main collection information was incorrect.
I posted similar question and answer was to use custom flag somewhere so I can continue from that flag.
Tried this solution, but it produced even more problems, as after start, maybe newer transaction will appair and my custom sync will downgrade information instead of upgrade (before it will run). So then I must check blocks, compare to current elements and decide what to do. This will be overkill.
So I decided to thow afterSave away and parse all information by myself. Then, it turns out that I can’t sort some columns in collection, as they are strings (and converting from string to int in query will have problems in future, it’s not resource friendly). I needed to convert it to int32 in order to use it properly. On forum, you answered me that I should create new column with same value but with int32, for example. (and I don’t like this approach, but, anyway let it be like that)
Then next problem appaired - we have option to transfer ownership of weapons. We can transfer either one or many items. It’s 2 separate collections, handling same data. So I need to select from both of them, sort it by certain column, and then do my stuff. It’s really uncomfortable to make queries like that and also keep track that new events will not make mess.
On my own server, I’d buld separate collection, that will hold both table data in same structure, by increment. But here, it’s unachievable as afterSave may not work for any reason.
This is my current state. I need your opinion, how I can handle this situation? Is it correct way for moralis? Should I use another approach?
Thanks!