feathersjs / docs

[MOVED] Legacy Feathers documentation
https://crow.docs.feathersjs.com/
MIT License
242 stars 532 forks source link

Paginate results from other API call #419

Closed idealley closed 7 years ago

idealley commented 7 years ago

I am not using a database adapter as I am calling another API. I have initialised the service as per the documentation:

  app.use('/articles', new Service({
    paginate: {
      default: 5,
      max: 20
    }
  }));

I have a a global hook that parses the received data. As I need to modify some fields such as markdown to html etc. I see that the data returned from the hook has the pagination object:

{ paginate: { default: 5, max: 20 } }

but I have the array return with all the objects (5 to 20) but I do not receive the "meta" object with the data property.

Does feathers js supports pagination without database adapter? How should I proceed?

Thank you

marshallswain commented 7 years ago

Hi @idealley, each of the database adapters has the pagination support built in. You might be able to take a look at the implementation and reproduce it for your API. If there were any kind of solid pagination standard, then out-of-the-box support for remote APIs would be a thing. As far as I know, it's not, so we have to roll our own. If it's an API that the rest of the public could use, then maybe you can create an adapter for it. That's how all of the adapters have been built up to now.

idealley commented 7 years ago

I see.

I think the adapter is the way to go. Is there some doc? or just dive in?

marshallswain commented 7 years ago

You can use the feathers plugin generator to get started. There's a guide here: https://docs.feathersjs.com/guides/creating-a-plugin.html

You'll probably just need to look at the pagination implementation in the existing adapters.

When you're ready, feel free to add it to the showcase page: https://docs.feathersjs.com/why/showcase.html