RavenDB RQL 中的 LastIndexOf?

问题描述

我正在寻找一种在 RQL 中进行字符串操作的方法我有一个字符串“xxx.yyy.zzz”,我想显示这个 zzz。我找到了 substr 函数,但找不到类似 lastindexof 的函数

解决方法

  1. 您可以对集合进行查询并使用 javascript 选择 (create a projection),
    然后使用您喜欢的任何方法,即lastIndexOf
    getParent(node,arr) {
        if (node && node.label) {
          let result;
          arr.unshift({
            key: node.tag,value: node.label,data: node.data
          })
          
          if (node.parent) {
            result = this.getchildren(node.parent,arr)
          } else {
            result = arr 
          }
          return result
        } else {
          this.initdata.ancestorValue = []
          arr = []
        }
    
      }
      getchildren(node,data: node.data
          })
          if (node.parent) {
            result = this.getParent(node.parent,arr)
          } else {
            result = arr 
          }
          return result
        }
        return arr      
    
      }

console.log(this.getParent(event.node,[]) 
  1. 您可以创建一个javascript索引并对其进行查询
    https://ravendb.net/docs/article-page/5.1/Csharp/indexes/javascript-indexes
    在 Map 方法中定义索引字段属性时使用任何 javascript 方法