在Azure移动服务JavaScript客户端中使用Like子句 [英] Using Like Clause in Azure Mobile Services JavaScript Client

查看:54
本文介绍了在Azure移动服务JavaScript客户端中使用Like子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Azure移动服务编写JavaScript客户端.查询表时,我试图在JavaScript Where子句中使用LIKE子句(或等效项). 有谁知道如何做到这一点? [本质上,我想查看字符串是否以特定值开头]

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 any one know how to do this? [Essentially I want to see whether a string starts with a particular value or not]

推荐答案

您可以使用indexOf函数,该函数支持该函数:

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));
});

这篇关于在Azure移动服务JavaScript客户端中使用Like子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆