Error updating user properties, missing ___class property for entity: friends

Hey guys, so I’ve got a friends column in the user’s table which is a one-to-many relationship to other users in the table. The problem is that whenever I try and update a property of the user, I get this error:


FAULT = '1020' [Missing ___class property for entity: friends] <Missing ___class property for entity: friends>

I don’t know why this error is happening, my workaround has been to update the friends along with the property I’m trying to update, which seems to work but I think there’s a better way to go about this.
Thanks guys

Please provide your code how do you get, change and update your entity.

I think the problems been with me messing with relationships. Here’s how I retrieve friends:









//MARK: Get Current User's Friends 

func getCurrentUsersFriends(tableView: UITableView){

    

    let whereClause = "objectId = '\(currentUser.objectId)'"

    let dataQuery = BackendlessDataQuery()

    let dataStore = backendless.persistenceService.of(BackendlessUser.ofClass())

    

    dataQuery.whereClause = whereClause

    

    dataStore.find(dataQuery, response: { (response : BackendlessCollection!) in

        if friendsArray.count > 0 {

            friendsArray.removeAll()

        }

        for test in response.data as! [BackendlessUser] {

            let userFriends = test.getProperty("friends")

            for friend in userFriends as! [BackendlessUser]{

                friendsArray.append(friend)

                tableView.reloadData()

            }

            ProgressHUD.dismiss()

            ProgressHUD.showSuccess("Friends Loaded")

            

        }

    }) { (fault : Fault!) in

        ProgressHUD.dismiss()

        ProgressHUD.showError(fault.detail)

        print("error fetching currentUserProperties : \(fault)")

    }

}

The friends are then referenced through the friendsArray, this function works fine.

How I add friends:









var userFriends = selectedUser?.getProperty("friends") as! [AnyObject]

            userFriends.append(currentUser)

            

            friendsArray.append(selectedUser!)

            currentUser.updateProperties(["friends" : friendsArray])

            selectedUser?.updateProperties(["friends" : userFriends])

            

            backendless.userService.update(selectedUser!, response: { (updatedUser : BackendlessUser!) in

                print("updated user = \(updatedUser)")

            }) { (fault : Fault!) in

                ProgressHUD.showError("Error adding as friend \(fault.detail)")

                print(fault)

            }

            

            backendless.userService.update(currentUser, response: { (updatedUser : BackendlessUser!) in

                ProgressHUD.showSuccess("\((self.selectedUser?.getProperty("username") as? String)!) added as friend")

                print("updated user = \(updatedUser)")

            }) { (fault : Fault!) in

                ProgressHUD.showError("Error adding as friend \(fault.detail)")

                print(fault)

            }

I think the problem could be here, but I don’t get any errors.

I also have two columns which are reported and blocked, when attempting to update these two I get the error.

Report users function?









    func reportUser(){

        var updatedReports = selectedFriend?.getProperty("reported") as! [AnyObject]

        updatedReports.append(currentUser)

        selectedFriend?.updateProperties(["reported" : updatedReports])

        

        backendless.userService.update(selectedFriend, response: { (response : BackendlessUser!) in

            ProgressHUD.showSuccess("Successfully reported user")

        }) { (fault : Fault!) in

            ProgressHUD.showError("Error reporting user: \(fault.detail)")

        }

    }

Block function:









    func blockUser(){

        var currentBlocked = currentUser.getProperty("blocked") as! [AnyObject]

        currentBlocked.append(selectedFriend!)

        currentUser.updateProperties(["reported" : currentBlocked])

        

        backendless.userService.update(currentUser, response: { (response: BackendlessUser!) in

            ProgressHUD.showSuccess("User Blocked")

        }) { (fault : Fault!) in

            ProgressHUD.showError("Error blocking: \(fault.detail)")

        }

    }

Lemme know if I’m going about updating the relationships incorrectly. They’re all on autoload btw.

Please, provide your appId here or to support@backendless.com, we need to investigate this issue with your data.

Sure, I’ll just give it here. It’s 6125020D-402E-ED8A-FFC0-60485ED4B000

Thanks

Any updates?

The internal task BKNDLSS-13085 is created.

Alright, thanks guys.

Hi Mudasar,

We cannot reproduce this issue with our sample project (see in attachment) and your app. We can update “reported” and “blocked” user properties without any faults. You can try it, how it will work for you?

Could you make some changes in our project so it will demonstrate the problem. Or provide your sample project which is able to reproduce this issue.

Regards,
Slava

TestUserUpdate.zip (20.55MB)

Thanks, I managed to fix the missing class error by using some of the sample code.

Thanks again