Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(query-typegoose): Adds the ability to use discriminators #1321

Merged
merged 8 commits into from
Sep 6, 2021
Merged

feat(query-typegoose): Adds the ability to use discriminators #1321

merged 8 commits into from
Sep 6, 2021

Conversation

smolinari
Copy link
Collaborator

Fixes #1320

Scott

@smolinari
Copy link
Collaborator Author

smolinari commented Aug 31, 2021

@doug-martin - I see I actually can merge this PR myself, but I'd like your review please, as I'm still not very good with TypeScript and I'm basically cheating by looking at another library for the solution (sort of). If you'd like more detail on that, let me know. I'm also uncertain about having all the tests copied and ran for the discriminated entity. I just thought it would be clear the discriminated entity would work 100% across the board with the query service. If I actually should add more tests, like in e2e, do let me know.

Ah, and basically, the goal is to allow for the below discriminator definition:

    moduleRef = await Test.createTestingModule({
      imports: [
        TypegooseModule.forRoot(await getConnectionUri(), {
          useFindAndModify: false,
          useNewUrlParser: true,
          useUnifiedTopology: true,
        }),
        NestjsQueryTypegooseModule.forFeature([
          {
            typegooseClass: TestEntity,
            discriminators: [TestDiscriminatedEntity], // <- this !!!!
          },
          TestReference,
        ]),
      ],
      providers: [TestDiscriminatedEntityService, TestReferenceService],
    }).compile();
  });

This is the actual docs on the topic:

Ah, and lastly, theoretically this could be good information for the docs. If you'd like, I can add a section about it, if you feel it is necessary.

Scott

@coveralls
Copy link

coveralls commented Aug 31, 2021

Pull Request Test Coverage Report for Build 1193990354

  • 14 of 16 (87.5%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 96.384%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/query-typegoose/src/providers.ts 14 16 87.5%
Totals Coverage Status
Change from base Build 1174129140: -0.06%
Covered Lines: 4921
Relevant Lines: 5010

💛 - Coveralls

@smolinari
Copy link
Collaborator Author

@JohnMcInall - would you be willing and have the time to look over this PR?

Scott

@doug-martin
Copy link
Owner

@smolinari I'm not super familiar with mongoose/typegoose and the more advanced features, but I'll take a look.

@smolinari
Copy link
Collaborator Author

@doug-martin - Ok. I'd appreciate any more experienced insights, even if it's not on the overall functionality, but more on the basic code level. If you say it's ok. I'll get it merged.

Scott

@llanicm
Copy link
Contributor

llanicm commented Sep 2, 2021

@smolinari I shall take a look when I have a little time today.

@smolinari
Copy link
Collaborator Author

Awesome @JohnMcInall. I appreciate it.

Scott

Copy link
Collaborator Author

@smolinari smolinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnMcInall - Puh. Only had a "Resolve Discussion" button and I clicked it and our discussion disappeared. But, I got what you said. Thanks!!! Commit is coming. Just have to figure out the GPG stuff. Been a while since I've worked with Github and PRs.

Scott

@smolinari smolinari merged commit 2a7da59 into doug-martin:master Sep 6, 2021
@smolinari
Copy link
Collaborator Author

@doug-martin - I've gone ahead and merged this. Hope that was ok.

Scott

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Currently the Nestjs-Typegoose package doesn't allow the use of discriminated entities.
5 participants