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

[Help] Is there a way to set default join? #54

Closed
Bnaya opened this issue Apr 1, 2019 · 5 comments
Closed

[Help] Is there a way to set default join? #54

Bnaya opened this issue Apr 1, 2019 · 5 comments

Comments

@Bnaya
Copy link

Bnaya commented Apr 1, 2019

I want some of my entities to make specific joins by default.
is there a way to declare that?

@michaelyali
Copy link
Member

I think you can do that at an Entity level. But CRUD lib doesn't have such functionality yet.

@Bnaya
Copy link
Author

Bnaya commented Apr 1, 2019

I couldn't find any way to do it directly at typeorm or crud,
So i've override method in my controller to inject params

  public async getOne(@ParsedQuery() query: any, @ParsedOptions() options: any) {
    if (this.base.getOneBase) {
      // console.log(query, options);
      if (!Array.isArray(query.join)) {
        query.join = [];
      }

      query.join.push({
        field: "categories",
        select: [],
      });

      // query.join.push({
      //   field: "categories.category",
      //   select: [],
      // });
      return this.base.getOneBase(query, options);
    }
  }

@zMotivat0r should i keep this issue open, as a feature request, or better close it?

@michaelyali
Copy link
Member

Yep, keep it, please. Will add this as a feature. Thanks!

@Bnaya
Copy link
Author

Bnaya commented Apr 2, 2019

Thank you!

@Bnaya Bnaya mentioned this issue Apr 15, 2019
@michaelyali
Copy link
Member

@Bnaya please see the docs

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

No branches or pull requests

2 participants