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.

fetchPage not working in current version

See original GitHub issue

We tried using fetchPage instead of fetch or fetchAll.

The default {page: 1, pageSize: 10} is returned.

However if we try including withRelated or different page and pageSize options it continues to return the default and does not work correctly. Anyone else experiencing this?

Here’s what a part of our code looks like:

fetchForCriteria: function (criteria) {
        return this.query(function (q) {
            for (var param in criteria) {

                if (criteria[param] == null || criteria[param] == undefined || criteria[param] == "")
                    continue;

                if (param == 'orderby') {
                    // q.orderBy(criteria[param], criteria['direction'] || 'desc');
                }
                else if (param == 'direction') {
                    continue;
                }
                else if (param == 'brand_id') {
                    continue;
                }
                else if (param == 'list_id') {
                    continue;
                }
                else if (param == 'image_id') {
                    continue;
                }
                else if (param == 'filter') {
                    var offer_ids = JSON.parse(criteria[param]);

                    if (offer_ids.length > 0) {
                        q.whereIn('id', offer_ids);
                    }
                }
                else if (param == 'name' || param == 'description' || param == 'requirements') {
                    q.where(param, 'ilike', '%' + criteria[param] + '%');
                }
                else {
                    q.where(param, '=', criteria[param]);
                }
            }
        })
        .orderBy('name')
        .fetchPage({    // fetchPage    // Not working for some reason
                    page: 2,    
                    pageSize: 5,
                   withRelated: ['lists', 'brands', 'status', 'offerType', 'images'] 
        });
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
thebergamocommented, Apr 20, 2017

Will be very useful if the @vellotis PR will be accepted. I’m having this problem.

4reactions
rmharrisoncommented, May 28, 2016

fetchPage() also seems to be broken for me on bookshelf v0.9.5

Works fine:

Data.query(function(qb) {
    ...
   })
  .fetchAll()
  .then(function(model) {
    return res.json(model);
    });
})

Doesn’t work:

Data.query(function(qb) {
    ...
   })
  .fetchPage()
  .then(function(model) {
    return res.json(model);
    });
})

Only difference is fetchAll() vs. fetchPage()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetch page data in background while returning current page
Issue is currently pull data calls both function sequentially and then returns, which makes UI to wait for the data. I want it...
Read more >
Bug#1009914: telegnome does not fetch page images
one of the latest updates of dependent packages telegnome does not work any more. The only message I get is: WARNING **: 17:01:40.546:...
Read more >
API Reference - Bookshelf.js
Automatically sets the current date and time on the timestamp attributes ... If the table you're working with does not have a Primary-Key...
Read more >
How to fetch Page Properties in JS in AEM 6.2
It would not work in any JS file like this. ... If you're looking to do this in the current version of AEM,...
Read more >
Troubleshooting WordPress Plugin Technical Issues
Domain is Authorized; Can Fetch Page Listing; Supported PHP Version; Supported Wordpress Version. 4. If any of the above checks have an 'X'...
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