You are right - you can use query.whereClause for one-to-many relation, and besides on the depth more then one. So, for fetching all users having part in the groups with currentUser you could find them in Users table using
query.whereClause = "groups.users.objectId = '\(backendless.userService.currentUser.objectId)'"
for example:
func getCommonGroupsUsersForCurrentUser() {
print ("\nCurrent User: \(backendless.userService.currentUser)\n")
// Create relation query for fetching the users relations
let query = BackendlessDataQuery()
// Where clause - find the all users having part in the groups with currentUser
query.whereClause = "groups.users.objectId = '\(backendless.userService.currentUser.objectId)'"
let dataStore = backendless.data.of(BackendlessUser.ofClass())
dataStore.find(
query,
response: {(bc : BackendlessCollection!) -> () in
let users = bc.getCurrentPage() as! [BackendlessUser]
for user in users {
print ("\(user.email)")
}
},
error: { (fault : Fault!) -> () in
print("Server reported an error (ASYNC): \(fault)")
})
}