I have a table TEAMS and another table USERS. Each TEAM record can have multiple USERS.
I’m trying to add an action where I can click on a user and add them to a team, appending them with all of the other users already on the team. Right now when I call the record it’s just overwriting any other users already on the team and adding just that one user I select.
OK so I tried to make this work, but it’s just replacing whatever value is in the field, not adding anything to it. Am I doing something wrong with my Array?
So that I understand correctly … are you just wanting to add the user to the Show Teams array on the front end? Or are you wanting to add the user in the backend Xano?
If you want to add it to the backend, you will need to handle that in the Xano API endpoint. In that scenario you’d want an endpoint that takes the team_id and the user_id as inputs, and then does a database transaction where Xano adds a new record to the DB to indicate a new user on the team.
If you just want this to happen on the front end, you can use the array functions @Joyce mentioned above. However, adding a user on the frontend using those functions will not add them to the database.
If you want to add a user to the JSON schema from your screenshot on the frontend, you will want to use something like add(Show Team[‘users_id’], {id:2,email:“john@aol.com” … first_name:“John”,etc,etc})
The JSON above for users_id is going to expect an object of type user.
Let me know what exactly you are wanting to do and I can provide some more input.