How do I get all documents after a date?

I want to get all expired documents, I have an index with expirationDate as it’s search term but this isn’t working for me.

try { 
    const r = await serverClient.query(
        Match(Index(`pending_payments_by_expirationDate`), faunadb.query.GTE(faunadb.query.Now())),

      Lambda('f', Get(Var('f')))
    return res.json(r)
  } catch (err) {
      return res.json(err)

You will want to create an index of all the pending payments without using any terms, and with values of expirationDate and ref (in that order). This will make it so that when you perform a Match on that index, it will have all of your pending payments in the set, sorted by expirationDate (but still also return the ref which I’m guessing you need).

Then use the Range function on that Set to only get the ones in the expired range.

1 Like