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: Separate update event into the update, soft remove and recover events #8403
Conversation
BEFORE_UPDATE_LISTENER_CALL
BEFORE_UPDATE_SUBSCRIBER_CALL
AFTER_UPDATE_LISTENER_CALL
AFTER_UPDATE_SUBSCRIBER_CALL
0 // <-- metadata.updateListeners.length
BEFORE_SOFT_REMOVE_SUBSCRIBER_CALL
AFTER_SOFT_REMOVE_SUBSCRIBER_CALL
BEFORE_RECOVER_SUBSCRIBER_CALL
AFTER_RECOVER_SUBSCRIBER_CALL
|
|
LOL. Did not expect checks will be passed so soon) Maybe there should be more checks? |
|
In Chinese documentation, I only changed English words 😶🌫️ |
Should there be tests for relations? |
docs/decorator-reference.md
Outdated
@@ -700,6 +706,82 @@ export class Post { | |||
|
|||
Learn more about [listeners](listeners-and-subscribers.md). | |||
|
|||
#### `@BeforeSoftRemove` | |||
|
|||
You can define a method with any name in the entity and mark it with `@BeforeRemove` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @BeforeRemove
should be @BeforeSoftRemove
here
docs/decorator-reference.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@BeforeRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
|
||
#### `@AfterSoftRemove` | ||
|
||
You can define a method with any name in the entity and mark it with `@AfterRemove` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@AfterRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@BeforeRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
|
||
#### `@AfterRecover` | ||
|
||
You can define a method with any name in the entity and mark it with `@AfterRemove` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@AfterRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/listeners-and-subscribers.md
Outdated
* [`@BeforeSoftRemove`](#beforeremove) | ||
* [`@AfterSoftRemove`](#afterremove) | ||
* [`@BeforeRecover`](#beforeremove) | ||
* [`@AfterRecover`](#afterremove) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect links all above ^
docs/listeners-and-subscribers.md
Outdated
@@ -89,6 +94,7 @@ export class Post { | |||
|
|||
You can define a method with any name in the entity and mark it with `@AfterUpdate` | |||
and TypeORM will call it after an existing entity is updated using repository/manager `save`. | |||
> :warning: **@AfterUpdate is no longer triggered by `softRemove` and `recover` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need these warnings above, just remove the all
docs/listeners-and-subscribers.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@BeforeRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/listeners-and-subscribers.md
Outdated
@Entity() | ||
export class Post { | ||
|
||
@BeforeRemove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same issue
docs/decorator-reference.md
Outdated
#### `@AfterSoftRemove` | ||
|
||
You can define a method with any name in the entity and mark it with `@AfterRemove` | ||
and TypeORM will call it after the entity is soft removed using repository/manager `remove`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using softRemove
?
docs/decorator-reference.md
Outdated
#### `@BeforeSoftRemove` | ||
|
||
You can define a method with any name in the entity and mark it with `@BeforeRemove` | ||
and TypeORM will call it before a entity is soft removed using repository/manager `remove`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using softRemove
?
* [`@BeforeSoftRemove`](#beforeremove) | ||
* [`@AfterSoftRemove`](#afterremove) | ||
* [`@BeforeRecover`](#beforeremove) | ||
* [`@AfterRecover`](#afterremove) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
links are broken ^
* [`@BeforeSoftRemove`](#beforeremove) | ||
* [`@AfterSoftRemove`](#afterremove) | ||
* [`@BeforeRecover`](#beforeremove) | ||
* [`@AfterRecover`](#afterremove) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
links are broken ^
|
||
### `@AfterSoftRemove` | ||
|
||
你可以在实体中定义一个具有任何名称的方法,并使用`@ AfterSoftRemove`标记它,TypeORM 将在使用 repository/manager `softRemove`删除实体后调用它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and missing spaces
|
||
### `@BeforeRecover` | ||
|
||
你可以在实体中定义具有任何名称的方法,并使用`@BeforeRecover`标记它,并且 TypeORM 将在使用 repository/manager `recover`删除实体之前调用它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and missing spaces
|
||
### `@AfterRecover` | ||
|
||
你可以在实体中定义一个具有任何名称的方法,并使用`@ AfterRecover`标记它,TypeORM 将在使用 repository/manager `recover`删除实体后调用它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and missing spaces
if (this.expressionMap.queryType === "soft-delete") | ||
await queryRunner.broadcaster.broadcast("BeforeSoftRemove", this.expressionMap.mainAlias!.metadata); | ||
else if (this.expressionMap.queryType === "restore") | ||
await queryRunner.broadcaster.broadcast("AfterSoftRemove", this.expressionMap.mainAlias!.metadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should be BeforeRecover
here?
Since this PR contains many small typos and copy-paste issues I recommend to go through the code once again (in case if I missing something) and make sure no issues left. Good job on a PR itself |
del |
@spotykatch were you able to fix the remaining issues before we can merge this one? |
Chinese docs are the only got left. I hope Chinese users will fix it themselves 😺 |
Closes: #8398 BREAKING CHANGE: update listeners and subscriber no longer triggered by soft-remove and recover
Closes: #8398
BREAKING CHANGE: update listeners and subscriber no longer triggered by soft-remove and recover
Fixes: #6179
Description of change
Separate update event into the update, soft remove and recover events
Pull-Request Checklist
master
branchnpm run lint
passes with this changenpm run test
passes with this changeFixes #0000