title: Cloud Firestore: query for an item's availability given a timestamp
body: <p>Imagine an Airbnb like app. A <code>rentals</code> collection contains documents with fields <code>start</code> and <code>end</code> of type timestamp that records the start date and end date of the rental (year, month and day only). Inside my Flutter app, when a user wants to make a new rental request, I need to check if the request interferes with any existing rentals. Would it be too much to store an array of <code>Timestamp</code> objects that contain the amount of days, then use <code>arrayContains</code> to query/check?</p>
  
  <p>For example:</p>
  
  <pre><code>rental #1
      start: Jan 1
      end: Jan 2
      days: [Jan 1, Jan 2]
  rental #2
      start: Jan 6
      end: Jan 10
      days: [Jan 6, Jan 7, Jan 8, Jan 9, Jan 10]
  </code></pre>
  
  <p>Suppose the user wants to book a rental for Jan 3-4. I would run a loop and query for documents with <code>arrayContains: Jan 3</code> and <code>arrayContains: Jan 4</code> and if it returns any documents, then I know the rental request date is invalid. The maximum amount of days a user can rent is 27 days, although I expect the average rental duration to last under 7 days. Is my method viable? I could change the maximum rental duration from 27 to 14 possibly.</p>
  
  <p>The other method I came up with is to query for the rentals immediately before and after the desired pickup time. So using the above example, if my desired rental date is Jan 3-4, I would query for the closest rental that ends before Jan 3 and the closest rental that starts after Jan 4. However, the issue I'm running into is what if the user in rental #1 decides to extend their rental from Jan 1-2 to Jan 1-3 (before our user is able to refresh their app)? Or if a particular listing has no rental history associated with it.</p>