Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to get a list of product from a specefic user in firebase #3206

Unanswered
takijemai asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 1 comment

Comment options

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.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /