Using FQL Lambda in Array functions

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Lambdas allow you to use functions like Map or Filter effectively in FQL. In this lesson we should the Lambda syntax by operating on some paginated results.

Paginate(Match(Index("all_customers")))
Map(
  Paginate(Match(Index("all_customers"))),
  Lambda("X", Get(Var("X")))
)

Instructor: [00:00] When running Paginate on a match of all documents in the index "all customers," we get back a list of refs. Let's say we want to get a field off of those refs. We could use Map and set up a Lambda. We'll have to give the argument a name -- in this case, X. The name here doesn't matter. It's only a reference to the argument. Use whatever makes you happy.

[00:25] Next, we'll access that variable using Var. The result of Var, in this case, is the ref from the set above. We can use Get to get the document. Note that now we have a list of all of the documents for all of the fields.

[00:44] When using a Lambda, you always have to give the argument a name and you always have to use Var to use the results of that variable. Once you use Var, you can use any other function you want, such as Get or Select.