Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
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:

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.ResolutionList = 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 Answer

0 votes
by (71.8m points)

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share