【问题标题】:How to implement Search using azure-mobile-apps-js-client如何使用 azure-mobile-apps-js-client 实现搜索
【发布时间】:2016-12-02 16:27:05
【问题描述】:

我有一个混合科尔多瓦应用程序,它使用javascript azure-mobile-apps-js-client 与服务器通信。数据也在设备上的 sqlite DB 中同步。

我需要通过全名对 Person 实体进行搜索。 应返回与搜索词匹配的所有人员(包含全名中的词)。 类似于 SQL 中的“LIKE”。

我确实阅读了this 文章,但没有找到方法。 似乎此客户端仅支持 =、>、<.> 等操作

这是否意味着我需要从表中检索所有记录并在客户端过滤它们(这对我来说听起来很奇怪)或者我只是遗漏了一些东西?

谢谢。

【问题讨论】:

    标签: javascript azure-mobile-services


    【解决方案1】:

    终于找到了一个使用 javascript string.indexOf 函数的选项。

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

    【讨论】:

    猜你喜欢
    • 2017-04-25
    • 1970-01-01
    • 2017-09-02
    • 2023-03-06
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    相关资源
    最近更新 更多