I have “order” table and there is 1to1 relationship on “client” table and 1to1 on “dealer” table, order (dealerId and clientId )and I have turned on “autoload” and the problem is that every retrieve request on the same object returns a different results, sometime it returns dealer object and client object is null, sometimes the client object but dealer object null and finally sometimes returns the both null.
Can you provide your App ID?
Is there any news? @Andriy_Konoz
I’m investigating problem
Can you also specify actual tables in which this problem occurs? Currently it is not enought information for narrowind down problem.
Is there a way to talk privately?
Unfortunatelly no. Private topics available only for holders of Backendless Pro-version.
But if you have to share some sensitive information - you can send it via direct messages.
@Hassan_Serhan I read your message and removed your messages with sensetive information.
I will look at your problem.
I will be waiting your reply.
I just checked the API Service, and I can see that you’ve got several
setRelation (without await) invocations which are running asynchronously and then without waiting a result you load the object by id, so you algorithm is:
- save an object
- assign relation-1 to the object
- assign relation-2 to the object
- assign relation-3 to the object
- assign relation-4 to the object
- assign relation-5 to the object
- load the object (findById) with autoload
setRelation method is async operation and when you request the object from the server there is no guarantee that all the relations above are already established, so that’s why you get a floating result
to solve the problem I can recommend you use
const savedObject = await save(...) await Promise.all([setRelation(...), setRelation(...), setRelation(...), setRelation(...)]) return findById(....)
Ah got it. But in my code I have:
“Backendless.Data.of( “user” ).setRelation(saveUser,“To”,[getUser.objectId] );”
Where I put the await Promise.all?
You must put Promise.all before find query since you want to be shure that all data-objects were created before query.
Thanks a lot! It works…