I have to documents in firestore one is user document and one is tweet document. I am trying to replicate the twitter clone. So my user has follower array. I want to display the user its tweet and its follower tweet. User collection is :
{
name:test,
email:test@gmail.com,
follower:[a@gmail.com,b@gmail.com]
}
Tweet Collection is:
{
text:Dummy tweet,
by:test@gmail.com,
img:dummyImageSource
}
I am not able to figure out. If I am logged in with test@gmail.com and I have one follower (let's say a@gmail.com). How will i need to query to fetch comment of mine(test@gmail.com) and all the follower(in this case a@gmail.com).
I have tried doing something like this :
db.collection("tweets")
.where("email", "==", this.state.user.email)//loggedin email
//need to add follower condition as well here so that i get combined tweet
.orderBy("created", "asc")
.onSnapshot(snapshot => {
let oldArr = [];
console.log(snapshot.docs)
snapshot.docs.forEach(doc => {
console.log(doc)
});