You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-9Lines changed: 54 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -19,24 +19,38 @@
19
19
npm install loopback4-soft-delete
20
20
```
21
21
22
+
**NOTE** - With latest version 3.0.0, you also need to install [loopback4-authentication](https://github.com/sourcefuse/loopback4-authentication) for using deleted_by feature added.
23
+
24
+
```sh
25
+
npm install loopback4-soft-delete
26
+
```
27
+
22
28
## Quick Starter
23
29
24
30
For a quick starter guide, you can refer to our [loopback 4 starter](https://github.com/sourcefuse/loopback4-starter) application which utilizes this package for soft-deletes in a multi-tenant application.
25
31
32
+
## Transaction support
33
+
34
+
With version 3.0.0, transaction repository support has been added. In place of SoftCrudRepository, extend your repository with DefaultTransactionSoftCrudRepository. For further usage guidelines, refer below.
35
+
26
36
## Usage
27
37
28
-
Right now, this extension exports two abstract classes which are actually helping with soft delete operations.
38
+
Right now, this extension exports three abstract classes which are actually helping with soft delete operations.
29
39
30
40
-**SoftDeleteEntity** -
31
41
An abstract base class for all models which require soft delete feature.
32
-
This class is a wrapper over Entity class from [@loopback/repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository) adding a new attribute 'deleted' (boolean) to the model class.
33
-
Same column is needed to be there in DB within that table.
42
+
This class is a wrapper over Entity class from [@loopback/repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository) adding three attributes to the model class for handling soft-delete, namely, deleted, deletedOn, deletedBy.
43
+
The column names needed to be there in DB within that table are - 'deleted', 'deleted_on', 'deleted_by'.
34
44
If you are using auto-migration of loopback 4, then, you may not need to do anything specific to add this column.
35
-
If not, then please add this column to the DB table.
45
+
If not, then please add these columns to the DB table.
36
46
-**SoftCrudRepository** -
37
47
An abstract base class for all repositories which require soft delete feature.
38
48
This class is going to be the one which handles soft delete operations and ensures soft deleted entries are not returned in responses at all.
39
49
This class is a wrapper over DefaultCrudRepository class from [@loopback/repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository).
50
+
-**DefaultTransactionSoftCrudRepository** -
51
+
An abstract base class for all repositories which require soft delete feature with transaction support.
52
+
This class is going to be the one which handles soft delete operations and ensures soft deleted entries are not returned in responses at all.
53
+
This class is a wrapper over DefaultTransactionalRepository class from [@loopback/repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository).
40
54
41
55
In order to use this extension in your LB4 application, please follow below steps.
42
56
@@ -63,18 +77,49 @@ export class User extends SoftDeleteEntity {
63
77
2. Extend repositories with SoftCrudRepository class replacing DefaultCrudRepository. For example,
0 commit comments