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.

egghead
egghead
~ 2 minutes ago

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

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

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!

Markdown supported.
Become a member to join the discussionEnroll Today