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.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!