Where Clause | Comparing relation with object | iOS Swift

Hello,
I’m currently working with Swift to migrate my app from Parse to Backendless and I’m facing a problem. In my app I have to retrieve all the objects created by the user. What I did with parse looked like that :

let query = PFQuery(className:"events")
query.whereKey("eventCreator", equalTo:currentUser!)

When I follow your documentation and try to do the same with Backendless, I get the following error « Invalid where clause »
Here is what my code look like :

let currentUser = backendless.userService.currentUser
let whereClause = "eventCreator = \(currentUser)"

So my question is : Is it possible to compare a relation with an object like the current user ?
Thanks !

Hi Nicolas,

You were close. If the “eventCreator” is a relation column, then the query will look like this (notice the single quotes around currentUser.objectId):

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

However, if it is a string and contains just the objectId value, then you’d do this:

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

Hope this helps.

Regards,
Mark

Thank you very much Mark !
Parse took me so far in his reality that I completely forgot some obvious things like this objectId comparaison logic. Never the less I wouldn’t have figured out the single quotes.