Paginating and passing other options with Paginate

Chris Biscardi
InstructorChris Biscardi
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Paginate can be used with options to move forward or backward in the list of results. We can also limit or expand the number of results we get in a Page.

Paginate(Match(Index("all_customers")))
Paginate(Match(Index("all_customers")), { size: 2 })
Paginate(
  Match(Index("all_customers")),
  {
    size: 2,
    after: Ref(Collection("customers"), "244075679455381001)
  }
)

Instructor: [00:00] In FQL, the paginate function takes a setter ref as the first argument. If you read the documentation, it may look like it takes a bunch of arguments after that. Let's take a look at passing the size argument to paginate.

[00:13] In the foreign DB shell, we have the function that paginates on the match of the index all customers. If we run this, we can see that we get four results. Let's add a size of two. As you can see, in our data, we now get two refs and then we have the next ref after it. We can expand on this by continuing to paginate.

[00:50] If we use the after ref, which is the third ref in the list, and we run this query, we get the last two results, and then we get a before field. As you can see, even though in the documentation it may look like paginate takes many arguments, it actually takes an object as a second argument.