ionicthemes / ion2fullapp

This is our public repository for customers to report bugs about Ion2FullApp - Ionic Template

Home Page:https://ionicthemes.com/product/ion2fullapp-full-ionic2-app-template-elite-version

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obtain Firestore Details on One page

Levy4u opened this issue · comments

Hello Again,

I'm trying to get the details from a specific collection/doc but all of examples in the template are either going from one page to another ( loading a collection, then passing the data of the one clicked on to the next page) or refreshing the data in a form to be modified and re-saved.

I'm looking at the firebase-integration.service.ts and don't see any that would return the data within 1 query.

For example... I have the collection People , then some documents that store the userID, name, avatar, etc. I know the userID I want but I cannot get just that 1 document that relates to the person. It seems I have to first use the searchPeople function to search through the collection and find the document by using the userID as the searchValue. Then I have to push it to a separate page passing along the data in which i then can use the this.item.payload.doc.data() to pull individual fields.

Problem is I cannot do all of this in one page and I need to, for the user profile. When the app I'm making opens, the root is a profile page so I need the data already loaded. There isn't a page where it shows the item collection then you click on it. I need it to just immediately search for the userID in the People collection, find it within the documents' fields, then return back just that 1 document and all the fields in it.

This is the adjusted firestore query i'm using on the profile page and it currently returns 1 item in the array, but since i'm navigating to another page, i have no where to pass the data to so I need to change this to get the document data fields right away.:

searchUsers(searchValue){ return new Promise<any>((resolve, reject) => { this.afs.collection('users', ref => ref.where('userID', '==', searchValue) .where('userID', '==', searchValue)) .snapshotChanges() .subscribe(snapshots => { resolve(snapshots); }) }) }

Thanks

Hey, do you still need help with this?