Git Product home page Git Product logo

Comments (10)

realityfilter avatar realityfilter commented on August 28, 2024 1

I stumbled upon this while adding limit(n) to my query as well. In middleware.js limit and skip are getting applied before the where clause. This seems to be a bug. See:

content/lib/middleware.js

Lines 76 to 104 in c5a11fc

if (params.skip) {
query = query.skip(params.skip)
}
if (params.limit) {
query = query.limit(params.limit)
}
if (params.only) {
query = query.only(params.only)
}
if (params.without) {
query = query.without(params.without)
}
if (params.where) {
const where = {}
for (const [key, value] of Object.entries(params.where)) {
const [field, operator] = key.split('_')
if (operator) {
where[field] = {
[`$${operator}`]: value
}
} else {
where[field] = value
}
}
query = query.where(where)
}
if (params.search) {

from content.

dtmzr avatar dtmzr commented on August 28, 2024 1

@realityfilter so skip and limit probably should be at the very end?

Gonna try it out later and create a PR if it solves the issue. :)

from content.

rajesh-h avatar rajesh-h commented on August 28, 2024 1

Thank you @dtmzr and @benjamincanac for keeping it rolling. Well Done !!!

from content.

rajesh-h avatar rajesh-h commented on August 28, 2024

I see problem might be at where I handle $fetch hook.

when we enter direct URL it runs on server so all goes well. But on client side same effect is not observed :(

Not sure how to handle this properly

from content.

dtmzr avatar dtmzr commented on August 28, 2024

Hey there, I removed this

      .skip(this.skipCnt)
      .limit(this.limitCnt)

from your query within MainBlock.vue. It seemed to help and your app delivered the right content in that case.

I guess the pagination mechanism has an unexpected side effect, let me know if you need help looking into it. :)

Heres the example:
https://codesandbox.io/s/nuxt-content-95-x4uyq?file=/pages/index.vue
(Note: due to removing skip/limit the infinite scroll is messed up in this example.)

from content.

rajesh-h avatar rajesh-h commented on August 28, 2024

@dtmzr Thank you very much for looking into it. Never thought this will be attended by anyone.

I think .limit() creates this issue only when you use along with .search() or .where() conditions.

Why I go with pagination mode is, lets say someone searches for word "veg" I have many tittles which has "veg" in it, so I want to show only 10 posts. so the page loads faster, also related images gets loaded only when the user wants to go down, else I might use my bandwidth of downloading 100 images which is unnecessary. Loading only when user goes down the screen saves the bandwidth in terms of users data as well.

Do you have any other way to manage this?

Thanks

from content.

dtmzr avatar dtmzr commented on August 28, 2024

I looked a little further into it but sadly couldn't resolve the issue.
In your case it seems to go wrong when the client tries to fetch this data, the server seems to retrieve it correctly.

You'll notice that if you reload the page - then the correct data should be in place.

I'll try to create a minimal poc to see if this is an implementation issue.

from content.

rajesh-h avatar rajesh-h commented on August 28, 2024

Yes I agree with you and realized it happens at client side.
One more thing is this behavior is not observed when I run as offline static site. after yarn generate then yarn serve.

Problem is during development SSR. If you can look into it that will be really helpful.

from content.

realityfilter avatar realityfilter commented on August 28, 2024

Yes. So you can paginate results matching a specific criteria.

from content.

dtmzr avatar dtmzr commented on August 28, 2024

Hey folks,
@benjamincanac just informed me within #267 that this issue should be fixed by #238. So we should be good to go after the next release.

@rajesh-h I tried out your app with the current dev version of content and everything worked as you would expect. 🙏

from content.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.