Unable to find clear where clause example

Hi,

I am working on Forgot Password which requests guest to enter their phone number then receive an SMS. once SMS verified, then he/she can reset password. When guest enter the mobile number, I want to do a query where I first see if the number exist as value in mobile column in the user table.

The best way I think to do this is to do a query with a where clause but it is really not very clear how to do it here. I found the below sample but unable to modify it to do the job:

func fetchingUsersAsync() {
    
        let dataStore = self.backendless.persistenceService.of(BackendlessUser.ofClass())
        dataStore.find(
            { (users : BackendlessCollection!) -> () in
                print("Users have been fetched  (ASYNC): \(users)")
            },
            error: { ( fault : Fault!) -> () in
                print("Server reported an error (ASYNC): \(fault)")
            }
        )
    }

I also looked at https://backendless.com/documentation/data/ios/data_search_and_query.htm but was unable to combine this with User table.

Thanks for the help in advance.

Hi, Khalid!

The samples for iOS Advanced Search should work for you.
Did you try ?

func findContactWhereAgeMore21() {
     
    let whereClause = "age > 21"
    let dataQuery = BackendlessDataQuery()
    dataQuery.whereClause = whereClause
     
    var error: Fault?
    let bc = backendless.data.of(Contact.ofClass()).find(dataQuery, fault: &error)
    if error == nil {
        print("Contacts have been found: \(bc.data)")
    }
    else {
        print("Server reported an error: \(error)")
    }
}

yes I did look at that earlier but it is not querying Users table and I believe user table would probably have a different way. Beside when I use the above, I don’t have a class called Contact and when I replace it with User it still highlights as error.

Do you still get errors if use BackendlessUser.ofClass() instead of Contact.ofClass() ?

No I got it to work but the returned data…How can i access it? I get this:

mobile have been found: [<BackendlessUser [<BackendlessUser: 0x7ff425c19b90>]> {
    "___class" = Users;
    "__meta" = "{\"relationRemovalIds\":{},\"selectedProperties\":[\"password\",\"created\",\"profilepic\",\"mobile\",\"name\",\"___class\",\"ownerId\",\"updated\",\"objectId\",\"email\",\"username\"],\"relatedObjects\":{}}";
    created = "2016-06-21 10:32:09 +0000";
    email = "useremail@gmail.com";
......

Is there a clear way to access the data?