Skip to content

How to retrieve a page containing a particular item (in the middle of a result set) #310

@JoeRoddy

Description

@JoeRoddy

Thanks for making this library! I've found it super useful :)

Here's my use case:
A user clicks to a video in the middle of a playlist of thousands of videos. I only want to send back the page that includes their video. Then, as they scroll up the playlist, I'll send back previous pages, and as they scroll down I'll send later pages.

Not sure if an option like that exists in this project, here's how I would imagine something like that working:

  const videoId = ARBITRARY_POSITION_IN_PLAYLIST
  const options = {  
    where: { playlistId }, 
    // some option like:
    page: { includes: { id: videoId} }
  };
  const { docs, pages, total, currentPage } = await Videos.paginate(options);
  // also needs to get the "currentPage" of the item, 
  // so the client knows how to grab prev/next item

Is there any type of api for something like this^^? Or will I have to write something custom?

Thanks!
-Joe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions