@comasoft/nestjs 0.0.92 → 0.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decorators/delete-columns.decorator.d.ts +1 -0
- package/dist/decorators/delete-columns.decorator.js +33 -0
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +1 -0
- package/dist/decorators/soft-delete.decorator.d.ts +1 -0
- package/dist/decorators/soft-delete.decorator.js +35 -0
- package/dist/decorators/timestamps.decorator.d.ts +0 -1
- package/dist/decorators/timestamps.decorator.js +6 -3
- package/dist/utils/pagination-qb.utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DeleteColumns(): (constructor: new (...args: any[]) => any) => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteColumns = DeleteColumns;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
function DeleteColumns() {
|
|
6
|
+
return function (constructor) {
|
|
7
|
+
(0, typeorm_1.Column)({
|
|
8
|
+
type: 'boolean',
|
|
9
|
+
default: false,
|
|
10
|
+
})(constructor.prototype, 'is_deleted');
|
|
11
|
+
(0, typeorm_1.Column)({
|
|
12
|
+
type: 'int',
|
|
13
|
+
nullable: true,
|
|
14
|
+
})(constructor.prototype, 'deleted_by');
|
|
15
|
+
(0, typeorm_1.Column)({
|
|
16
|
+
type: 'timestamp',
|
|
17
|
+
precision: 3,
|
|
18
|
+
nullable: true,
|
|
19
|
+
})(constructor.prototype, 'deleted_at');
|
|
20
|
+
Object.defineProperty(constructor.prototype, 'deleted_by', {
|
|
21
|
+
set(value) {
|
|
22
|
+
this._deleted_by = value;
|
|
23
|
+
if (value !== null) {
|
|
24
|
+
this.is_deleted = true;
|
|
25
|
+
this.deleted_at = new Date();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
get() {
|
|
29
|
+
return this._deleted_by;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}
|
package/dist/decorators/index.js
CHANGED
|
@@ -21,3 +21,4 @@ __exportStar(require("./user.decorator"), exports);
|
|
|
21
21
|
__exportStar(require("./auth.decorator.factory"), exports);
|
|
22
22
|
__exportStar(require("./cookies.decorator"), exports);
|
|
23
23
|
__exportStar(require("./timestamps.decorator"), exports);
|
|
24
|
+
__exportStar(require("./soft-delete.decorator"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SoftDelete(): (constructor: new (...args: any[]) => any) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SoftDelete = SoftDelete;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
function SoftDelete() {
|
|
6
|
+
return function (constructor) {
|
|
7
|
+
(0, typeorm_1.Column)({
|
|
8
|
+
type: 'boolean',
|
|
9
|
+
default: false,
|
|
10
|
+
})(constructor.prototype, 'is_deleted');
|
|
11
|
+
(0, typeorm_1.Index)('idx_deleted_id', ['is_deleted', 'id'])(constructor);
|
|
12
|
+
(0, typeorm_1.Column)({
|
|
13
|
+
type: 'int',
|
|
14
|
+
nullable: true,
|
|
15
|
+
unsigned: true,
|
|
16
|
+
})(constructor.prototype, 'deleted_by');
|
|
17
|
+
(0, typeorm_1.Column)({
|
|
18
|
+
type: 'timestamp',
|
|
19
|
+
precision: 3,
|
|
20
|
+
nullable: true,
|
|
21
|
+
})(constructor.prototype, 'deleted_at');
|
|
22
|
+
Object.defineProperty(constructor.prototype, 'deleted_by', {
|
|
23
|
+
set(value) {
|
|
24
|
+
this._deleted_by = value;
|
|
25
|
+
if (value !== null) {
|
|
26
|
+
this.is_deleted = true;
|
|
27
|
+
this.deleted_at = new Date();
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
get() {
|
|
31
|
+
return this._deleted_by;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -5,18 +5,21 @@ const typeorm_1 = require("typeorm");
|
|
|
5
5
|
function Timestamps(options = {
|
|
6
6
|
created_at: true,
|
|
7
7
|
updated_at: true,
|
|
8
|
-
deleted_at: true,
|
|
9
8
|
}) {
|
|
10
9
|
return function (constructor) {
|
|
11
10
|
if (options.created_at !== false) {
|
|
12
|
-
(0, typeorm_1.CreateDateColumn)({
|
|
11
|
+
(0, typeorm_1.CreateDateColumn)({
|
|
12
|
+
type: 'timestamp',
|
|
13
|
+
precision: 3,
|
|
14
|
+
default: () => 'CURRENT_TIMESTAMP(3)',
|
|
15
|
+
})(constructor.prototype, 'created_at');
|
|
13
16
|
}
|
|
14
17
|
if (options.updated_at !== false) {
|
|
15
18
|
(0, typeorm_1.Column)({
|
|
16
19
|
type: 'timestamp',
|
|
17
20
|
precision: 3,
|
|
18
21
|
default: null,
|
|
19
|
-
onUpdate: '
|
|
22
|
+
onUpdate: 'CURRENT_TIMESTAMP(3)',
|
|
20
23
|
nullable: true,
|
|
21
24
|
})(constructor.prototype, 'updated_at');
|
|
22
25
|
(0, typeorm_1.BeforeUpdate)()(constructor.prototype, 'updateDate');
|