-
Notifications
You must be signed in to change notification settings - Fork 2.2k
-
i 'm using ionic+firebase to get a list of product for a specific user in firebase , but i can't get it this list?
i have 2 users every user have a list of product , the problem is how i can get this list without the login of his user
i m new with ionic and firebase
thanks
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
You could do something like this:
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
// Replace `userId` with the actual user ID you want to retrieve the list of products for
const userId = 'user123';
export class ProductService {
constructor(private firestore: AngularFirestore) {}
getProductsForUser(): Observable<any> {
return this.firestore
.collection('users')
.doc(userId)
.collection('products')
.valueChanges();
}
}
I assumed you have a "users" collection in Cloud Firestore with documents for each user, and a "products" subcollection under each user's document with the list of their products.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment