Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(service): refactor delete API #762

Merged
merged 1 commit into from
Oct 29, 2021
Merged

Conversation

oceanlvr
Copy link
Contributor

@oceanlvr oceanlvr commented Oct 29, 2021

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

delete message > 1000 work as we expect.

Issue Number

#749

What is the new behavior?

Please describe the new behavior or provide screenshots.

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

Are there any specific instructions or things that should be known prior to review?

Other information

@oceanlvr oceanlvr added the fix Fix bug or issues label Oct 29, 2021
@oceanlvr oceanlvr requested a review from ysfscream October 29, 2021 06:32
@oceanlvr oceanlvr self-assigned this Oct 29, 2021
return
}
return await this.messageRepository.remove(query)
await this.messageRepository.delete(query.map((entity) => entity.id) as string[])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove does not support a count of more than 1000 entity deletion.

Copy link
Member

Choose a reason for hiding this comment

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

So the reason why you can't clear the message is that you're using the wrong API and there's no limit to the number of messages after the current change remove to delete?

Copy link
Contributor Author

@oceanlvr oceanlvr Oct 29, 2021

Choose a reason for hiding this comment

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

Yes,delete won't check the entity exist or not, just follow the id field and there is no delete count limit.

  • remove, return the data deleted, and count < 1000 once, it's safe but slow.
  • delete, don't check anything, so you should check id exists before deleting. it's unsafe but quick and has no limit on counting.

Copy link
Member

Choose a reason for hiding this comment

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

COOL!

@ysfscream ysfscream merged commit 82b088a into emqx:master Oct 29, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
fix Fix bug or issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants