【问题标题】:Parse query string in JavaScript WHERE in Query在 Query 中的 JavaScript WHERE 中解析查询字符串
【发布时间】:2020-07-03 22:38:58
【问题描述】:

我有一个包含 Description 字段的 Parse 类。 我想搜索描述中包含任何单词的所有实例。

例如,在从 Angular Web 应用程序搜索时,用户输入 "tourism hotels and hospitals" 我可以对他输入的内容进行拆分:["tourism", "hotels", "and", "hospitals"]。 现在我想从类中查询 Parse 中的所有记录,它的描述字段包含这些单词中的“任何”。

有什么想法吗??请不要使用Parser.Query.or 编写god knows how many 查询

谢谢,

【问题讨论】:

    标签: javascript parsing parse-platform back4app


    【解决方案1】:

    将描述字段与数组匹配?

    ['Tourism is a fantastic', 'opportunity', 'to sell hotel rooms', 'at good prices','and drink beer', 'with the rest of your hotels friends']
        .filter( entry => entry.match( new RegExp( (["tourism", "hotels", "and", "hospitals"]).join('|'), 'gi' ) ) )
    

    【讨论】:

      【解决方案2】:

      使用包含在 中,像这样

      var listOfWords= ["tourism", "hotels", "and", "hospitals"];
      query.containedIn("Description", listOfWords);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-06
        • 2020-01-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多