Using Like Clause In Azure Mobile Services Javascript Client
I am writing a JavaScript client for an Azure Mobile Service. I am trying to use the LIKE clause (or equivalent) in the JavaScript Where clause, when I am querying a table. Does an
Solution 1:
You can use the indexOf
function, which is supported in the function:
var table = client.getTable('tableName');
var queryValue = document.getElementById('txtField').value;
table.where(function(startsWith) {
return this.name.indexOf(startsWith) === 0; // for 'contains', use >= 0
}, queryValue).read().done(function(results) {
alert('Results: ' + JSON.stringify(results));
}, function(err) {
alert('Error: ' + JSON.stringify(err));
});
Post a Comment for "Using Like Clause In Azure Mobile Services Javascript Client"