Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JoeRoddy opened this issue Apr 15, 2020 · 0 comments

Comments

@JoeRoddy
Copy link

JoeRoddy commented Apr 15, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant