Firebase query to only return new posts?
<p>I'm fairly new with firebase so my lack of code isn't a lack of trying more of a just "I dont really know where to begin here".</p>

<p>I'm trying to only show posts that are 10 minutes "old" or less. I'm going to run a timer in my app to send the query every second (assuming this doesn't cause too much of an issue?) to check to make sure the current posts aren't over that 10 minute mark, and if they are, the query just shouldn't return them.</p>

<p>I've got it set up where when the user makes a post a timestamp is created. </p>

<p>The setup is :</p>

<pre><code>Posts 
   02983094jfksdflkaj3l
      timestamp: 23478923019
</code></pre>

<p>I'm assuming I need to orderByValue? to sort the posts by the timestamp and then return it with a limit of some sort, but I'm not sure how to map all of that out.</p>

<p>A point in the right direction would be greatly appreciated here.</p>

<p>Thanks in advance!</p>

<p>edit: I'm no longer getting any posts appearing in the collectionview...and no matter how many posts I have that should satisfy the under 10 minute query, only one ever returns.</p>

<p>Like I show below, I'm not getting a .value return on the snap...which should return the timestamp value I get shown in the timestamp snap print, no?</p>

<pre><code> override func viewWillAppear(animated: Bool) {
    let cutoff = UInt64(1000 * floor(NSDate().timeIntervalSince1970) - 10*60*1000);
    let cutoffFloat = Float(cutoff) // &lt;-- woudnlt take a UInt64 as an AnyObject. I assume its ok to just do this?


    DataService.ds.REF_POSTS.queryOrderedByChild("timestamp").queryStartingAtValue(cutoffFloat).observeSingleEventOfType(.ChildAdded) { (snapshot: FIRDataSnapshot) in
        print("child added") // &lt;------- isn't ever getting called
        self.Posts = []
      if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot] {

            for snap in snapshots {

             print("timestamp snap: \(snap)") // &lt;---- returns timestamp snap: Snap (timestamp) 23904819242

                      if let postDict = snap.value as? Dictionary&lt;String, AnyObject&gt; {

                    print(snap.value)// &lt;----- Returns nothing
                    let key = snap.key
                    let post = Post(postKey: key, dictionary: postDict)
                    self.Posts.append(post)

                }
            }
        }

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

<p>}</p>

<p>I don't know if it's any help but here was my code I was using before to populate the collection view:</p>

<pre><code>   DataService.ds.REF_POSTS.observeEventType(.Value) { (snapshot: FIRDataSnapshot) in

        self.Posts = []
        if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot] {

            for snap in snapshots {

                print(snap)

                if let postDict = snap.value as? Dictionary&lt;String, AnyObject&gt; {
                    let key = snap.key
                    let post = Post(postKey: key, dictionary: postDict)
                    self.Posts.append(post)
                }
            }
        }

       print("got here")
       self.collectionView.reloadData()


    }
</code></pre>