Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 离子色谱中角度火源表的搜索函数_Javascript_Angular_Firebase_Ionic Framework_Firebase Realtime Database - Fatal编程技术网

Javascript 离子色谱中角度火源表的搜索函数

Javascript 离子色谱中角度火源表的搜索函数,javascript,angular,firebase,ionic-framework,firebase-realtime-database,Javascript,Angular,Firebase,Ionic Framework,Firebase Realtime Database,要让这个搜索功能正常工作,我有点头疼。我现在有它的设置,所以它会得到正确的项目,当我搜索它,但它的拼写必须是准确的,包括大写和标点符号。我希望它能够得到的项目,无论用户的搜索词的大小写,如果他们只是键入字母“b”,它将包括在项目字段中有一个“b”的所有项目 我知道我想查询对数据库的调用,因为在客户端这样做会非常繁重,但你们怎么想,或者你们将如何实现这一点 setFilteredItems() { this.employeeListRef = this.database.list('

要让这个搜索功能正常工作,我有点头疼。我现在有它的设置,所以它会得到正确的项目,当我搜索它,但它的拼写必须是准确的,包括大写和标点符号。我希望它能够得到的项目,无论用户的搜索词的大小写,如果他们只是键入字母“b”,它将包括在项目字段中有一个“b”的所有项目

我知道我想查询对数据库的调用,因为在客户端这样做会非常繁重,但你们怎么想,或者你们将如何实现这一点

 setFilteredItems() { 

    this.employeeListRef = this.database.list('userProfile', 
    ref=> ref.orderByChild('lastName'));


    this.employeeList = this.employeeListRef.snapshotChanges()
    .map(
      changes => {
        return changes.map(c => ({
          key: c.payload.key, ...c.payload.val()
        }))
      }
    );

    //if searchterm is null it returns so it can set back the list to all values
    //searchterm is declared in constructor
    if(!this.searchTerm) {
      return;
    }

    //var term = this.searchTerm.toLowerCase();

    this.employeeListRef = this.database.list('userProfile', 
    ref => ref.orderByChild('lastName').equalTo(term));


      this.employeeList = this.employeeListRef.snapshotChanges()
      .map(
        changes => {
          return changes.map(c => ({
            key: c.payload.key, ...c.payload.val()
          }))
        }
      );


  }
如果您查看,您可以很好地了解Firebase是如何存储其记录的,以及orderByChild可能无法按预期工作的原因

b是98,b是66。它们在ASCII表上的不同位置

有两件事可以帮助您访问所需表达式中的数据

尝试与的用户将可搜索数据转换为小写 使用云函数,在写入记录时,在对象中保存该记录的小写版本,然后按该记录进行搜索。例如:

{ lastName: 'Smith', lowercaseLastName: 'smith' }
然后您可以使用orderByChild'LowercaseAlstName'