Get user from firebase



The script is to put results in firestore and that is no problem. Only thing is that every user sees all inputted items. What can be the best way to only see what user a inserted(user a items) and not what user b insert?

My guess is to use login name or something. I have already an option to use google login with Firebase but how can I combine the firebase login to check with the item in Firestore?

//import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore';
import firebase from 'firebase';

  Generated class for the TodosProvider provider.

  See for more info on providers
  and Angular DI.
export class TodosProvider {

  constructor(public db: AngularFirestore) {
	  console.log('Hello TodosProvider Provider');

	 list() {

   return this.db.collection('/todos', ref => ref.orderBy('complete').orderBy('text')).valueChanges();


 add(text) {

   const id = this.db.createId();

   return this.db.collection('todos').doc(id).set({

     id: id,
     text: text,

     complete: false,

     createdAt: firebase.firestore.FieldValue.serverTimestamp(),

     updatedAt: firebase.firestore.FieldValue.serverTimestamp()



 complete(todo) {

   return this.db.collection('todos').doc({

     complete: todo.complete,

     updatedAt: firebase.firestore.FieldValue.serverTimestamp()



 delete(todo) {

   return this.db.collection('todos').doc(;




Hey @RenzoM78

Here’s how I would approach this:

I would create a collection of users and inside of each user document add the user’s TODOs as a sub-collection, so the end result would be something like this in the database:


Then you can fetch the user-specific to-dos in your application


Thankyou @javebratt :slight_smile: I found this yesterday:

And that is sort of the same you say to do.


Yeah, Jeff has many great videos on angular-firebase stuff.


I understand the part of a collection bur what I dont understand is how do I get a user uid from the logged in user into firestore.


You need to save it yourself, once you create a new user, add the user info to a users/ collection in Firestore


I have this Angular tutorial off how to do this:

But I cant get this working into Ionic, is there also a tutorial for Ionic how to do this with users? and data?