Mix data from 2 tables in ONE parameter in a Return Data Api

Hello everyone,

The context is not really complicated. I have 2 tables :

  • User : {email(text), permanentAccess[linkedPermanentAccessArray] , FullName(text), FirstName(text)}
  • PermanentAccess : {code(text), Client(linkedUser)

So, the operation is quite simple. A user can have SEVERAL permanent accesses, so an array and conversely, a permanent access to a SINGLE user

My problem is the following : I would like to display the information for each Client searched in the PermanentAccess table and the id of the permanent access in question

To be clearer,

As you can see, I return a parameter “userPM” which is type User. In this parameter, I search the Permanent Access table for each Customer item.

So, I manage to retrieve the Client information, except in this case I can’t retrieve the permanent access id for each Client.

Ideally, I would like to have this:
userPM: [{
email: [email protected],
permanentAccess : [“123”, “456”] ,
FirstName : toto,
FullName : donald,
_idUser : “5461165145513”
_idPermanentAccess: “123} ,
{email : [email protected],
permanentAccess : [“587”, “581”, 972”] ,
FirstName : auntie,
FullName : Jeremy
_idUser : “21025464651”
_idPermanentAccess: "581}]

_idPermanentAccess is the id of the Permanent Access !

But today, I dont find the solution to retrieve the right _idPermanentAccess directly in the response…

Dont hesitate to ask me if this is not clear enough.

Thanks in advance

PS: Obviously, if my method is not good, I am ready to change my way of doing things