@bedrockio/model 0.2.4 → 0.2.5
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/cjs/soft-delete.js +20 -5
- package/package.json +1 -1
- package/src/soft-delete.js +40 -5
- package/types/soft-delete.d.ts.map +1 -1
package/dist/cjs/soft-delete.js
CHANGED
|
@@ -55,7 +55,10 @@ function applyQueries(schema) {
|
|
|
55
55
|
|
|
56
56
|
schema.static('deleteOne', function deleteOne(filter, ...rest) {
|
|
57
57
|
const update = getDelete();
|
|
58
|
-
const query = this.updateOne(
|
|
58
|
+
const query = this.updateOne({
|
|
59
|
+
...filter,
|
|
60
|
+
deleted: false
|
|
61
|
+
}, update, ...omitCallback(rest));
|
|
59
62
|
return (0, _query.wrapQuery)(query, async promise => {
|
|
60
63
|
const res = await promise;
|
|
61
64
|
return {
|
|
@@ -66,7 +69,10 @@ function applyQueries(schema) {
|
|
|
66
69
|
});
|
|
67
70
|
schema.static('deleteMany', function deleteMany(filter, ...rest) {
|
|
68
71
|
const update = getDelete();
|
|
69
|
-
const query = this.updateMany(
|
|
72
|
+
const query = this.updateMany({
|
|
73
|
+
...filter,
|
|
74
|
+
deleted: false
|
|
75
|
+
}, update, ...omitCallback(rest));
|
|
70
76
|
return (0, _query.wrapQuery)(query, async promise => {
|
|
71
77
|
const res = await promise;
|
|
72
78
|
return {
|
|
@@ -76,10 +82,16 @@ function applyQueries(schema) {
|
|
|
76
82
|
});
|
|
77
83
|
});
|
|
78
84
|
schema.static('findOneAndDelete', function findOneAndDelete(filter, ...rest) {
|
|
79
|
-
return this.findOneAndUpdate(
|
|
85
|
+
return this.findOneAndUpdate({
|
|
86
|
+
...filter,
|
|
87
|
+
deleted: false
|
|
88
|
+
}, getDelete(), ...omitCallback(rest));
|
|
80
89
|
});
|
|
81
90
|
schema.static('restoreOne', function restoreOne(filter, ...rest) {
|
|
82
|
-
const query = this.updateOne(
|
|
91
|
+
const query = this.updateOne({
|
|
92
|
+
...filter,
|
|
93
|
+
deleted: true
|
|
94
|
+
}, getRestore(), ...omitCallback(rest));
|
|
83
95
|
return (0, _query.wrapQuery)(query, async promise => {
|
|
84
96
|
const res = await promise;
|
|
85
97
|
return {
|
|
@@ -89,7 +101,10 @@ function applyQueries(schema) {
|
|
|
89
101
|
});
|
|
90
102
|
});
|
|
91
103
|
schema.static('restoreMany', function restoreMany(filter, ...rest) {
|
|
92
|
-
const query = this.updateMany(
|
|
104
|
+
const query = this.updateMany({
|
|
105
|
+
...filter,
|
|
106
|
+
deleted: true
|
|
107
|
+
}, getRestore(), ...omitCallback(rest));
|
|
93
108
|
return (0, _query.wrapQuery)(query, async promise => {
|
|
94
109
|
const res = await promise;
|
|
95
110
|
return {
|
package/package.json
CHANGED
package/src/soft-delete.js
CHANGED
|
@@ -48,7 +48,14 @@ function applyQueries(schema) {
|
|
|
48
48
|
|
|
49
49
|
schema.static('deleteOne', function deleteOne(filter, ...rest) {
|
|
50
50
|
const update = getDelete();
|
|
51
|
-
const query = this.updateOne(
|
|
51
|
+
const query = this.updateOne(
|
|
52
|
+
{
|
|
53
|
+
...filter,
|
|
54
|
+
deleted: false,
|
|
55
|
+
},
|
|
56
|
+
update,
|
|
57
|
+
...omitCallback(rest)
|
|
58
|
+
);
|
|
52
59
|
return wrapQuery(query, async (promise) => {
|
|
53
60
|
const res = await promise;
|
|
54
61
|
return {
|
|
@@ -60,7 +67,14 @@ function applyQueries(schema) {
|
|
|
60
67
|
|
|
61
68
|
schema.static('deleteMany', function deleteMany(filter, ...rest) {
|
|
62
69
|
const update = getDelete();
|
|
63
|
-
const query = this.updateMany(
|
|
70
|
+
const query = this.updateMany(
|
|
71
|
+
{
|
|
72
|
+
...filter,
|
|
73
|
+
deleted: false,
|
|
74
|
+
},
|
|
75
|
+
update,
|
|
76
|
+
...omitCallback(rest)
|
|
77
|
+
);
|
|
64
78
|
return wrapQuery(query, async (promise) => {
|
|
65
79
|
const res = await promise;
|
|
66
80
|
return {
|
|
@@ -71,11 +85,25 @@ function applyQueries(schema) {
|
|
|
71
85
|
});
|
|
72
86
|
|
|
73
87
|
schema.static('findOneAndDelete', function findOneAndDelete(filter, ...rest) {
|
|
74
|
-
return this.findOneAndUpdate(
|
|
88
|
+
return this.findOneAndUpdate(
|
|
89
|
+
{
|
|
90
|
+
...filter,
|
|
91
|
+
deleted: false,
|
|
92
|
+
},
|
|
93
|
+
getDelete(),
|
|
94
|
+
...omitCallback(rest)
|
|
95
|
+
);
|
|
75
96
|
});
|
|
76
97
|
|
|
77
98
|
schema.static('restoreOne', function restoreOne(filter, ...rest) {
|
|
78
|
-
const query = this.updateOne(
|
|
99
|
+
const query = this.updateOne(
|
|
100
|
+
{
|
|
101
|
+
...filter,
|
|
102
|
+
deleted: true,
|
|
103
|
+
},
|
|
104
|
+
getRestore(),
|
|
105
|
+
...omitCallback(rest)
|
|
106
|
+
);
|
|
79
107
|
return wrapQuery(query, async (promise) => {
|
|
80
108
|
const res = await promise;
|
|
81
109
|
return {
|
|
@@ -86,7 +114,14 @@ function applyQueries(schema) {
|
|
|
86
114
|
});
|
|
87
115
|
|
|
88
116
|
schema.static('restoreMany', function restoreMany(filter, ...rest) {
|
|
89
|
-
const query = this.updateMany(
|
|
117
|
+
const query = this.updateMany(
|
|
118
|
+
{
|
|
119
|
+
...filter,
|
|
120
|
+
deleted: true,
|
|
121
|
+
},
|
|
122
|
+
getRestore(),
|
|
123
|
+
...omitCallback(rest)
|
|
124
|
+
);
|
|
90
125
|
return wrapQuery(query, async (promise) => {
|
|
91
126
|
const res = await promise;
|
|
92
127
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"AAKA,mDAIC;
|
|
1
|
+
{"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../src/soft-delete.js"],"names":[],"mappings":"AAKA,mDAIC;AAoTD,oEAsBC;AAgDD,2DAKC"}
|