Moralis API call vs Database Query

Hello all,

I have the following situation:

when clicking on a button in react, a user will have to execute a set of transaction, depending on a condition. This condition is based on the past execution of a blockchain transaction.

At the moment i see 2 options to solve this problem:

Option n1:
-> step1: for each new connected user, do a moralis apicall with useMoralisWeb3Api on a contract to get the result of a view function, to check if this user executed the blockchain transaction.

Option n2:
-> build a table in Moralis Database, based on the past transaction events, of the user which executed the transaction in the past. Then, for each new connected user, do a query with useMoralisQuery to check if this user executed the blockhain transaction in the past.

What’s the best practice in this case? API call or database query? The result is very important and have to be without error, the response time or other consideration don’t matter.

it is easier to make an API call, not too many other steps in order to validate the data

I tried with a database, but i was stucked at one point. I was able to do a query,filter and get the raw result (all the columns from the select lines).

Nevertheless, when i wanted to get some attributes in particular, it was not possible, the only way was to do it manually from the browser console (Invoke property getter)

here are some screenshots:

Screenshot from 2022-09-13 16-28-55
Screenshot from 2022-09-13 16-29-02
Screenshot from 2022-09-13 16-29-12
Screenshot from 2022-09-13 16-29-27

At the end, doing:
_ useMoralisQuery({...}).data was fine
_ useMoralisQuery({...}).data.attributes.myAttributes get me an error. It seems to be a basic Javascript error, but i didn’t find the trick to solve it by myself (outside manually using the browser console)

With a database, is it the best practice or i should do something different? i will try with an API call anyways.

it can depend from case to case on how you can access that data, sometimes it works with .get, sometimes .attribute sometimes how you wrote, sometimes with [‘variable’], sometimes by converting it to JSON and then back to an object