Server side Logic

Hi, I am trying to build some kind of server side logic because of security reasons.

This is the UI we are looking for:
Image1

The green button means that the event contains “currentUser.objectId”.

This is the database structure:
Image2

And this is the logic I am trying to build:
Image3

My questions are:

  1. How can I achieve the If block in the image 3 without having to load all object Id’s of other users stored in “registered_users”?

  2. Is it possible to do all the logic on the server and simply send a response like:

If currentUser is stored in registered_users
[object]
-event_name: “Musik Concert”
-registered_users: [{}]
–objectId: “currentUser.objectId

If currentUser is not stored in registered_users
[object]
-event_name: “Musik Concert”
-registered_users: [{}]
–objectId: null

Even if there are other users registered but not the current user?

Hello @Rafael_Cunha,

  1. How can I achieve the If block in the image 3 without having to load all object Id’s of other users stored in “registered_users”?

You can use the following where clause:
registered_users = 'object-id-of-your-user'
Such where clause will filter only those events where registered_users contains specified objectId.

  1. Is it possible to do all the logic on the server and simply send a response like:

Yes, you can change your response in any way you’d like.

Regards,
Stanislaw

Thank you for the fast answer!

In my case, what is the proper way to think about it? The option 1 will not work because I also want to load other events so the user can register to them.

Where can I find more information how o manipulate a response on the block “load Table objects” without loading the whole thing?

Hi, I apologize but I cannot find the answer to my questions. Would you please elaborate?

Hello, @Rafael_Cunha.

Sorry for the long delay.

We have so many courses and videos at our YouTube channel.
Also, you can find information here.
And a link to our codeless documentation. However, it is still being supplemented, so it may not contain all the information.

Best Regards, Nikita.

What does the “registered_users” refer to?

If you’re talking about the logic illustrated in the diagram, the answer is yes.

It is refering to the database structure on the image 2.

To check if the Events table has a related user through the registered_users column, you could do the following:
Run a find query (Load Table Objects) for the Events table with the following where clause:

registered_users.objectId = 'objectId of the current user'

If you get back empty collection, it means there are no events for the current user. If you get a non-empty collection, it will contain events of the current user.

Hope this helps.

Mark