Git Product home page Git Product logo

Comments (4)

Devorein avatar Devorein commented on July 21, 2024 1

You, my friend, are a lifesaver. I was hesitant on trying Ben's solution on using raw SQL for joining and then mapping the values using json function, but since this works it has saved me hours. Many thanks.

from lireddit.

Devorein avatar Devorein commented on July 21, 2024 1

I think there is still a bit more optimization that could be done here. For example, this will always join the post and user table, even if the query didn't ask for the creator fields. In that case, checking the info object to see if the query contains the creator field and only joining it would be better.

from lireddit.

AaronMcCloskey avatar AaronMcCloskey commented on July 21, 2024 1

Thank you! This is great, I thought having to write SQL was a bit more effort and assumed it could have been achieved with the queryBuilder

Although, I think;

qb.limit(realLimit);

should be

qb.limit(realLimit + 1);

and in the return

return {
  posts: posts.slice(0, realLimit),
  hasMore: posts.length === realLimit + 1,
};

Or instead of realLimit + 1 use the variable reaLimitPlusOne

For the hasMore functionality to work correctly.

from lireddit.

SergeNarhi avatar SergeNarhi commented on July 21, 2024

Possible solution typeorm/typeorm#747 (comment)

from lireddit.

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.