How to only show friend's posts? Swift / Firebase
<p>I just implemented a friend adding system and I'm scratching my head on how to only allow users to see friend's posts. </p>

<p>On my main screen where I'm displaying posts, I've got :</p>

<pre><code>DataService.ds.REF_USERS.child(currentUser!).child("friends").observeSingleEventOfType(.Value) { (snapshot: FIRDataSnapshot) in

            for snapshots in snapshot.children.allObjects {
                let snap = snapshots as! FIRDataSnapshot
                var frand = String(snap.key)   
                self.friendsArray.append(frand)
            }
</code></pre>

<p>which pulls back the UID of all their friends.</p>

<p>I then want to search through all posts that have that UID as a child.</p>

<p>I figured maybe I could do a for-loop through the friendsArray with an equalTo query...? but then I'm not sure how to implement that with my currently existing query that shows back posts that I'm wanting to see :</p>

<pre><code>DataService.ds.REF_POSTS.queryOrderedByChild("timestamp").queryStartingAtValue(cutoff).observeEventType(.ChildAdded, withBlock: { (snapshot:FIRDataSnapshot) in
</code></pre>

<p>-bunch of code that sets up my post and appends it to an array-</p>

<pre><code>        self.collectionView.reloadData()

    })
</code></pre>

<p>Some of my data structure is :</p>

<pre><code>users
     3093098409384
        friends
            29834098209 : true

posts
     099390234
         userWhoPosted: 29834098209
</code></pre>

<p>So I'm pulling the friends out of the users-> friends -> UID bit, but how do I then get back posts made by those users, and THEN carry out my normal query back I'm doing?</p>

<p>Any guidance is appreciated.</p>