Oskar
Oskar

Reputation: 135

How to implement Search using azure-mobile-apps-js-client

I have a hybrid cordova app which uses javascript azure-mobile-apps-js-client for communicating with server. Data is also synchronized in sqlite DB on device.

I need to implement search against Person entities by their Full Names. All persons which matches search term(contains term inside Full Name) should be returned. Something like "LIKE" in SQL.

I did read this article but didn't found a way to do that. Seems like this client is supporting only operations like =, >, <.

Does it mean I need to retrieve all records from table and filter them on client (which sounds weird to me) or I just missing something ?

Thanks.

Upvotes: 0

Views: 95

Answers (1)

Oskar
Oskar

Reputation: 135

Finally found an option to do that using javascript string.indexOf function.

//Declare a query
function queryFunction(term){
     return this.FullName.indexOf(term) != -1
}

//Pass it to where function
table
    .where(queryFunction, term)
    .read()
    .then(success, failure);

Upvotes: 1

Related Questions