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

Can't remove on Many-To-Many relations #31

Closed
izundo-viennv opened this issue Feb 23, 2020 · 3 comments
Closed

Can't remove on Many-To-Many relations #31

izundo-viennv opened this issue Feb 23, 2020 · 3 comments

Comments

@izundo-viennv
Copy link

Hi @doug-martin,
I trying to add a many relation to my user resolver, I can call add many, but I can't call with remove many and it reports an error like this:

image

image

@izundo-viennv
Copy link
Author

izundo-viennv commented Feb 23, 2020

@doug-martin I debugged and found that position of parameters (relationName and id) are wrong in the file relation-query.service.ts

  async removeRelations<Relation>(
    id: string | number,
    relationName: string,
    relationIds: (string | number)[],
  ): Promise<DTO> {
    const entity = await this.repo.findOneOrFail(id);
    await this.createRelationQueryBuilder(entity, relationName).remove(relationIds);
    return this.assembler.convertToDTO(entity);
  }

It should be

async removeRelations<Relation>(
    relationName: string,
    id: string | number,
    relationIds: (string | number)[],
  ): Promise<DTO> {
    const entity = await this.repo.findOneOrFail(id);
    await this.createRelationQueryBuilder(entity, relationName).remove(relationIds);
    return this.assembler.convertToDTO(entity);
  }

@izundo-viennv
Copy link
Author

I'm glad if you give me permissions to create PR for this issue

doug-martin added a commit that referenced this issue Feb 23, 2020
* [FIXED] Can't remove on Many-To-Many relations [#31]
doug-martin added a commit that referenced this issue Feb 23, 2020
* [FIXED] Can't remove on Many-To-Many relations [#31]
@doug-martin
Copy link
Owner

Fixed and published @nestjs-query/[email protected]

Thanks for the bug report!

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