Relating object in different table to users table

Android

Do you have an actual value for guest_id so we can test what objects are returned from the Following table?

Iā€™d like to make sure we get actual objects using Backendless Console

The Id am supposed to receive is the users objectId but it isnā€™t. Eg. Id - E4B2D43E-B95A-EB4A-FFF4-05FC436CFE00

Sorry, I didnā€™t understand. What is this ID?

The guest object_id. That an sample of what am supposed to receive from the Users table to relate to Following table in a column guest_id. So onclick of it (the Id)directs me to that guest user object in the Users table.

If I understood you correctly you have that value the guest_id column in the Following table. Is that correct?

Do this just to check:

  1. Open Backendless Console
  2. Switch to the Data section
  3. Select the Following table
  4. Enter this in the search bar:
guest_id = 'E4B2D43E-B95A-EB4A-FFF4-05FC436CFE00'

Do you get any objects back?

no. No data to display.

No the value isnā€™t in the guest_id column of Following table yet. That I copied from the Users table showing what am supposed to see.

I just tried something different now. I deleted the guest_id on the Following table now and created it again but this time made It a string and not an object reference. And what I wanted worked right how I wanted it. But the problem is the guest_id now is a strong so I canā€™t directly reach the userā€™s data on the Users table, I will have to copy the string guest_id and now find it in the Users table.

I am getting all confused with the information you provide. So I will basically reiterate what the docs say:

This is the code to create a relation. You need to put the right values in here such as:

  1. objectId of the parent object
  2. name of the column in the Following table (the code below shows it as columnNameInFolloring
  3. where clause to identify the children
HashMap<String, Object> parentObject = new HashMap<String, Object>();

// the value here MUST BE the objectId of the User object which is the "parent"
parentObject.put( "objectId", "41230622-DC4D-204F-FF5A-F893A0324800" );

Backendless.Data.of( "Users" ).setRelation( parentObject, 
                                             "columnNameInFolloring:Following:n", 
                                             "WHERE CLAUSE TO IDENTIFY THE CHILDREN", 
                                             new AsyncCallback<Integer>()
{
  @Override
  public void handleResponse( Integer response )
  {
    Log.i( "MYAPP", "relation has been set" );
  }

  @Override
  public void handleFault( BackendlessFault fault )
  {
    Log.e( "MYAPP", "server reported an error - " + fault.getMessage() );
  }
} );

The where clause here is referring to what table.

To the table where the child objects are.

Finally got it. Tanx Mark

1 Like