question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server-Side-Pagination with Composition API

See original GitHub issue

Hello, I try to get Server-Side-Pagination with the Composition API up and running. The component I use is a quasar table (https://quasar.dev/vue-components/table#Server-side-pagination%2C-filter-and-sorting).

setup(props, context) {

      const { Buildings } = context.root.$FeathersVuex.api;

      const pagination = reactive({
        sortBy: 'name',
        descending: false,
        page: 1,
        rowsPerPage: 10,
        rowsNumber: 0
      });

      const queryParams = computed(() => {
        return {
          query: {
            $sort: { name: 1 },
            $limit: pagination.rowsPerPage,
            $skip: 0
          },
          paginate: true
        }
      });

      const { items: buildings, paginationData } = useFind({
        model: Buildings,
        params: queryParams
      });

      function onRequest(requestProps) {
        const { rowsPerPage } = requestProps.pagination;
        pagination.rowsPerPage = rowsPerPage;
      }

      return {
        buildings,
        hasLoaded,
        pagination,
        queryParams,
      }
    }

In https://vuex.feathersjs.com/composition-api.html#options it states “Set params.paginate to true to turn off realtime updates for the results and defer pagination to the API server. Pagination works the same as for the makeFindMixin pagination.”. However, I don’t want to turn off realtime updates -> if records come in that match the currently shown page these should replace the current page. If I set paginate to true, no rows are fetched from the server with the above setup.

I have three questions:

  • What am I missing to get the above code up and running and keep getting realtime updates?
  • How can I initiate the first request?
  • How can I get the total number of rows after the request has finished? I need to set pagination.rowsNumber and there is no callback or promise for paginationData to decide when to receive the information from paginationData (already saw total in there).

Thanks for your help in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
olegdevcommented, Mar 24, 2020

I found solution like: :total="latestQuery && latestQuery.response ? latestQuery.response.total : 0"

0reactions
marshallswaincommented, Apr 30, 2020

@olegdev That is exactly the way it was intended to be used. Thank you for sharing. I’m going to close up this issue as it seems to be working after the fixes deployed in version 3.7.

The only feature left in this issue that’s not fully implemented is 100% realtime support. Realtime updates are supported for individual records, so we still get realtime support that way. However, keeping paginated lists realtime is a bigger scope than I’m willing to take on right now. I still haven’t even found a logical solution that would be accurate in every use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue3: Reusable client side pagination with the composition API
I recently built a pagination component using the composition API. In this post I'm sharing my solution for doing client side pagination.
Read more >
Vue Pagination with Axios and API (Server Side ... - BezKoder
In this tutorial, I will show you how to make Pagination in a Vue.js Application with existing API (Server Side pagination) using Axios...
Read more >
Vue.js + Node - Server Side Pagination Tutorial & Example
This is a simple example of how to implement server-side pagination in Vue.js with a Node.js backend API. The example contains a hard...
Read more >
server side pagination in vue js - YouTube
Hey Guyz,It is a sample about server side pagination in vue js. you first should have pagination API where we will get total...
Read more >
Pagination - Microservice API Patterns
Many public Web APIs use Pagination; typically both Page-Based and Offset-Based and Cursor-Based Pagination are supported while the Time-Based Pagination ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found