angularfire5和firebase自动完成功能等同于哪里?

时间:2019-02-07 04:47:12

标签: angular firebase firebase-realtime-database angularfire2 angularfire5

我使用angularfire2 v5为firebase提供的自动完成服务如下:

getUsersTypeAhead(searchString: string) {
    const list: AngularFireList<User> = this.fireBase.list('/users', ref => ref
        .orderByChild('name')
        .limitToFirst(10)
        .startAt(searchString)
        .endAt(searchString + '\uf8ff')
    );
    return list.snapshotChanges().pipe(
        map(items => items.map(item => ({
            key: item.key,
            name: item.payload.val().name
        })))
    );
}

但是,这似乎区分大小写。这是一个限制,还是存在与mySQL中的WHERE LIKE类似的查询?

1 个答案:

答案 0 :(得分:0)

在这里Making a firebase query search NOT case sensitive

查看此答案
getUsersTypeAhead(searchString: string) {
    const list: AngularFireList<User> = this.fireBase.list('/users', ref => ref
        .orderByChild('name')
        .limitToFirst(5)
        .startAt(searchString.toUpperCase())
        .endAt(searchString.toLowerCase() + '\uf8ff')
    );
    return list.snapshotChanges().pipe(
        map(items => items.map(item => ({
            key: item.key,
            name: item.payload.val().name
        })))
    );
}