Is there a way to operate with Map on all values returned from the index?


I want to operate on all results returned from any index.
For this, I use the Paginate function at this stage and give you a high value.

The Map function cannot be used directly with the Match function because it requires Array.

Is there a way to operate with Map on all values returned from the index?

Not directly. Match returns a set reference, and as you noted, Map takes an array.

By design, Fauna does not permit you to perform queries that could exhaust server resources or interfere with other users querying their databases.

To retrieve items from a set, you need to use Paginate. If the number of entries is larger than 64 (Paginate's default page size), you can increase the page size up to 100,000. If the number of entries is larger than that, you have no choice but to issue multiple Paginate queries, passing the appropriate cursor each time, until all items have been retrieved. See the documentation for details: Paginate | Fauna Documentation

I was wondering if there is a solution without using Page for results less than 100,000.

Right now I am already using Page.
In fact, if the Map processed a maximum of 100,000 results when the Set was sent, there would be no need to use Page.
I’m guessing, a very large developer base is already using Page by giving a big number.

Thank you.

Reduce can be used to convert a Set to another data type without needing to use Paginate.

Except for all of the users who don’t want/need to grab 100000 records at once. The default is set to a lower number specifically so that you are required to change it when you need something different. FQL is super powerful, but does come at a cost of being lower-level and you being aware of how the queries are run.

Fascinating and confirmed. Does it fail if the Set contains more than 100000 documents? That I cannot confirm (don’t have the capacity to test).

Reducing a Set definitely opens possibilities for better readability, when Reduce already makes sense.

While returning a list of Refs, it doesn’t. @hasimyerlikaya example Maps the identity function, Lambda("x", Var("x")). At that point just Paginate, and don’t use Map.

Paginate(Match(/* ... */), { size: 100000 }) // no Map necessary

If you want an extra step to list the documents, say with Get, which one is more readable?

  (acc, ref) => Append(acc, [Get(ref)]), 
  Match(/* ... */)

// OR

  Paginate(Match(/* ... */), { size: 100000 }),
  ref => Get(ref)