我使用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类似的查询?
答案 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
})))
);
}