Giter Site home page Giter Site logo

Comments (6)

ppetzold avatar ppetzold commented on June 12, 2024

try relations: { any: { nested: { relation: true } } }

from nestjs-paginate.

Helveg avatar Helveg commented on June 12, 2024

It doesn't appear to work, no error is thrown but no nested relationships are loaded either:

      async findAll(@Paginate() query: PaginateQuery) {
        return await paginate(query, this.service.repo, {
          ...this.options.pagination,
          relations: {bankAccount: {organization: true}}
        });
      }

but the returned page is:

Paginated {
  data: [
    Payout {
      id: 'b18b40f3-08ac-428e-9712-ada46fd0a4a5',
      createdAt: 2023-09-07T14:50:43.000Z,
      updatedAt: 2023-09-07T14:50:43.000Z,
      deletedAt: null,
      amount: null,
      paidAt: null
    },
...

Passing that same nested object {bankAccount: { organization: true } } to a TypeORM relations field does load the relationships.

In any case, after figuring this out, would you accept a PR that lets users use the dotted notation as well?

from nestjs-paginate.

ppetzold avatar ppetzold commented on June 12, 2024

In any case, after figuring this out, would you accept a PR that lets users use the dotted notation as well?

Yep. Certainly, I actually thought the above was an alternate typeORM definition as well. If not, then I would almost say we drop it and adapt the typeORM way only in a breaking change.

from nestjs-paginate.

Helveg avatar Helveg commented on June 12, 2024

The problem was resolved by updating my version (sorry about that).

I also reviewed the TypeORM docs and the object notation is the the only mentioned notation. On StackOverflow users answer with both, so somehow this dotted notation does circulate. I'd propose for my support to add non-breaking support for the dot notation then.

The dot notation (relations: string[]) does have official support, and we could use the same utility snippet they use to convert between them:

                const relations = Array.isArray(this.findOptions.relations)
                    ? OrmUtils.propertyPathsToTruthyObject(
                          this.findOptions.relations,
                      )
                    : this.findOptions.relations

https://github.com/typeorm/typeorm/blob/befe4f9cbf17139bfaba83ae8a00e56b071df334/src/query-builder/SelectQueryBuilder.ts#L3097-L3101

I'll start on the PR

from nestjs-paginate.

ppetzold avatar ppetzold commented on June 12, 2024

sounds good to me 🚀

from nestjs-paginate.

ppetzold avatar ppetzold commented on June 12, 2024

🎉 This issue has been resolved in version 8.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from nestjs-paginate.

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.