如何在azure-mobile-apps-js-client中使用substringof [英] How to use substringof in azure-mobile-apps-js-client
问题描述
我想通过azure-mobile-apps-js-client使用odata substringof方法. 当前,我使用indexof方法,但想切换到substringof.
I want to make use of odata substringof method using azure-mobile-apps-js-client. Currently I use indexof method but want to switch to substringof.
我有此代码
function queryFunction(term){
return this.FullName.indexOf(term) != -1
}
table.where(queryFunction, term)
翻译为
$filter=indexof(FullName, term) ne -1
我需要这样的网址:
filter=substringof(term, FullName) eq true
如何使用javascript做到这一点?
How do I do that with javascript ?
推荐答案
azure-query-js
支持一组有限的Javascript函数,这些函数可以转换为它们的odata等效项.当前,没有可以映射到substringof
的功能.使用indexOf
的原始实现是使用Javascript样式查询来查询子字符串的最佳选择.
azure-query-js
supports a limited set of Javascript functions that are translated to their odata equivalents. Currently, there is no function that can be mapped to substringof
. Your original implementation using indexOf
is your best bet for querying for substrings using Javascript style querying.
但是,如果希望完全控制自己的查询,则可以将OData查询字符串直接传递给read
方法. https://github.com/Azure/azure-mobile-apps-js-client/blob/2b5e083d400a089cb1759d6d58d96e4d10ba2310/sdk/test/tests/shared/mobileServiceTables.js#L98 是一个示例.如果您在文件中搜索'$filter'
,则会找到更多示例.
However, if you wish to take complete control of querying yourself, you can directly pass an OData query string to the read
method. https://github.com/Azure/azure-mobile-apps-js-client/blob/2b5e083d400a089cb1759d6d58d96e4d10ba2310/sdk/test/tests/shared/mobileServiceTables.js#L98 is an example. If you search for '$filter'
in the file you will find a few more examples.
这篇关于如何在azure-mobile-apps-js-client中使用substringof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!