So I have created a new database table under the name of ‘ColorPalette’. That table contains a few columns, from which the one is called ‘likes’. That column is a relational column. And it’s referencing the actual Users table.
Now from my Android app, I’m trying to update that relational column (likes), whenever a user clicks a button. And when that happens a new value (User) inside that relational column should appear.
Now I’m confused how to achieve that exactly, because whenever I execute that, I receive all my users inside that relational column (likes) and not just the single currently logged in user like I want.
Backendless.Data.of(ColorPalette::class.java)
.addRelation(
ColorPalette(
objectId = "037EF750-1AF7-4AC6-8CA1-47315B38D2D7",
likes = listOf(
Users(
id = "106446187796280519744"
)
)
),
"likes",
"",
object : AsyncCallback<Int> {
override fun handleResponse(response: Int?) {
Log.d("BackendlessDataSource", "$response")
}
override fun handleFault(fault: BackendlessFault?) {
Log.d("BackendlessDataSource", fault?.message.toString())
}
})
Here I’m passing the actual User Id of the user I want to add to that relational column (likes). I’m getting that User Id from the currently logged in user bw: Backendless.UserService.CurrentUser().userId
And also for the testing purpose I’ve hard-coded the actual objectId of the row/entry which I want to update.