how to get specific and limited checked data from

2019-04-16 09:45发布

basically, I want to get limited data from firestore to use for autocomplete. I use a way that is: "to get all data from the database and string match that data" but this method is too slow. Basically, I stored data like this table->id's -> data. I want to write a query that retrieves data for example: if I write a word in input autocomplete the query would get the 5 to 10 specific values and on second input words it again runs and gets more specific from firestore. The conclusion is that I want to match string on real time from firestore to autocomplete input field.

1条回答
祖国的老花朵
2楼-- · 2019-04-16 10:36

I got the solution. and the solution was so simple

searchArea(start){
  const end = start + '\uf8ff';
  return this.afs.collection('areas', ref => 
    ref
      .orderBy('title')
      .limit(5)
      .startAt(start)
      .endAt(end)
  ).snapshotChanges();
}

server-side API code to filter with a very fast and quick response.

查看更多
登录 后发表回答