Map/Paginate/Lambda/Update Only updates first page when running in the Web Shell

I am trying to add a reference to all documents in Collection A to a corresponding document in Collection B. I was just going to so it in the web shell because I am just correcting an oversight that happened when I initially brought the data into these collections. My Map() function I wrote worked exactly how I wanted to except I believe it only ran the update I wanted on the first page of my index. I pasted my FQL below. Is there anyway to have this run on all documents in my collection? Maybe Paginate(Documents(Collection('Customers'))) instead of using Index(). Thanks so much!

Map(
  Paginate(Match(Index("getAllCustomers"))),
  Lambda(
    ["customer"],
    Update(Var("customer"), {
      data: {
        salesRef: Select(
          "ref",
          Get(
            Match(
              Index("getSalesmenByNumber"),
              Select(["data", "salesmanNumber"], Get(Var("customer")))
            )
          )
        )
      }
    })
  )
)

My collection has fewer than 100,000 documents so I think I can just pass in a size parameter to paginate and return everything that way. Is this the way to do it or is there a more ‘correct’ way? :slight_smile: Thanks again!

If your collection has fewer than 100K documents, using the size parameter is certainly a solution.

If you have more than 100K documents, or your overall update transaction would take more than 30 seconds (which is the limit for any transaction), you would need to issue multiple queries to iterate over each page of documents. It is possible to do that work manually, but writing client code is often the better approach.

FaunaDB doesn’t allow you to perform arbitrarily large transactions because it is a shared database service for many, many databases. Large transactions can block other processing until they are complete. Small transactions complete faster and give all transactions a chance to complete in a timely manner.

For more information on Pagination, see these documentation topics: