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:[email protected],
follower:[[email protected],[email protected]]
}
Tweet Collection is:
{
text:Dummy tweet,
by:[email protected],
img:dummyImageSource
}
I am not able to figure out. If I am logged in with [email protected] and I have one follower (let's say [email protected]). How will i need to query to fetch comment of mine([email protected]) and all the follower(in this case [email protected]).
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)
});