I’m having trouble listening to relation updates on user objects.
What I want to do from a browser UI is to register a new user and assign it to a company, which is a separate table. I’ve made a 1:1 relation on the user to the company table. In order to create the relation I firstly create the user and then I create the relation with the setRelation function I get from the Backendless JS lib. However, this does not trigger an update event on the user object. If I change the name of a user I do get an update event.
Oh, so you mean there is none what-so-ever. Does this mean changes for all kind of relations are not pushed? Or is it only for relations on the User object?
This then means that we cannot have a decent table architecture and have fully real-time data in our app. Do you have any work-arounds or tips on how to achieve this? How could I best handle my case?
How likely is it that you guys will implement this anytime soon?
I would not say that not being able to track the state of the relations in real-time would prevent you from having a decent table architecture. With that premise all the solutions built on top of mysql, oracle and SQL server would need to be discarded… The Internet as we know it would be dead
A workaround you could consider implementing is adding event handlers in the cloud code for the addRelation/setRelation events:
How would I go about this if the relation is added to a User object. If I select Users as Category, I dont have an addRelation event. Only if I choose Data Tables, but it seems Users do not fall in that Category.
Any tips?
I guess I could check the other way around. So make it so that a company has many users instead of a user had 1 company. What do you think?
Users is just another table in the database, so go ahead and use Data, then you can scope the event to that table.
When you select Users as the category, you’re going down the path of creating an event handler for the Users-related APIs, such as login, registration, password recovery, etc.
However, it is quite some work to set this up for al the relation updates in several tables. The combination of setting relations on an object in a separate call then the creation call of that object and setting up custom pub/sub logic for all relation fields both in the frontend and in de backend(business logic of Backendless) to listen to those relation changes feels like a lot of work where I was kind of expecting that the out-of-the box real-time solution would cover such cases.
Do not get me wrong, I am glad I can make it work with this work-around, but I was wondering if relation updates would become something the RT db would cover in the near future.
We are pleased that the proposed solution has helped you. We have already created an internal ticket BKNDLSS-20460 and will discuss the possibility of adding relation listeners. Your subscriptions are currently a workaround to solve your problem.
The intent is to add support for real-time listeners for relation changes. When it is implemented, you will not need to do the messaging workaround.
The change you requested is already added to the road-map. To make it happen we will need to change the core app server to track the changes and modify all the RT-enabled SDKs (Android, iOS, JS, .NET) to include support for relation listeners. Additionally, we’ll need to modify the documentation to reflect the changes. While it seems like a simple change on the server, all other tasks do increase the scope.