Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

firebase - angular.js firestore returns null when using query

I am trying to query against a firestore database, however, when I use a query it will return null.

What I would like to do is pass an id from a document in one collection, and get the corresponding results from another collection. I have no problem getting, the id, but when I try to use in the firestore query, that is where I am having issues. This is the the code I am using the query against the collection:

GetResolutions(id){
return this.fs.collection('resolution', ref=> ref.where('category','==',id)).snapshotChanges();
}

And this is where I am using the return statement:

ngOnInit(): void {
    const id = this.route.snapshot.paramMap.get('id');
    this.rs.GetResolutions(id).subscribe(data=>{
      this.ResolutionList = data
      console.log(data)
    })
}

When I console log out my id, it matches what I have inside the firestore. If I replace the variable 'id' with an actual id it again works and will return the correct documents. Again, however, if I try to use the variable 'id' I am returning an empty array. I know that I am missing something, but I am not sure what.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...