How to use substringof in azure-mobile-apps-js-client

↘锁芯ラ 提交于 2019-12-11 04:59:02

问题


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.

I have this code

function queryFunction(term){
     return this.FullName.indexOf(term) != -1
}
table.where(queryFunction, term)

Which translates to

$filter=indexof(FullName, term) ne -1

I need URL like this:

filter=substringof(term, FullName) eq true

How do I do that with javascript ?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/41076143/how-to-use-substringof-in-azure-mobile-apps-js-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!