prisma-mock 0.0.30 → 0.0.33
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/README.md +5 -4
- package/lib/index.js +31 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,8 +104,8 @@ Alot of the functionality is implemented, but parts are missing. Here is a list
|
|
|
104
104
|
- distinct
|
|
105
105
|
- include
|
|
106
106
|
- where
|
|
107
|
-
-
|
|
108
|
-
-
|
|
107
|
+
- select
|
|
108
|
+
- orderBy
|
|
109
109
|
- TODO: select: _count
|
|
110
110
|
|
|
111
111
|
## Nested queries
|
|
@@ -113,12 +113,13 @@ Alot of the functionality is implemented, but parts are missing. Here is a list
|
|
|
113
113
|
- createMany
|
|
114
114
|
- update
|
|
115
115
|
- updateMany
|
|
116
|
+
- delete
|
|
117
|
+
- deleteMany
|
|
116
118
|
- connect
|
|
119
|
+
- disconnect
|
|
117
120
|
- TODO: set
|
|
118
|
-
- TODO: disconnect
|
|
119
121
|
- TODO: connectOrCreate
|
|
120
122
|
- TODO: upsert
|
|
121
|
-
- TODO: delete
|
|
122
123
|
|
|
123
124
|
|
|
124
125
|
## Filter conditions and operators
|
package/lib/index.js
CHANGED
|
@@ -178,6 +178,22 @@ const createPrismaMock = async (data = {}, pathToSchema, client = (0, jest_mock_
|
|
|
178
178
|
delegate.delete({ where: c.delete });
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
if (c.disconnect) {
|
|
182
|
+
if (field.relationFromFields.length > 0) {
|
|
183
|
+
d = Object.assign(Object.assign({}, d), { [field.relationFromFields[0]]: null });
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const joinfield = getJoinField(field);
|
|
187
|
+
delegate.update({
|
|
188
|
+
data: {
|
|
189
|
+
[joinfield.relationFromFields[0]]: null
|
|
190
|
+
},
|
|
191
|
+
where: {
|
|
192
|
+
[joinfield.relationFromFields[0]]: item[joinfield.relationToFields[0]]
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
181
197
|
const _e = d, _f = field.name, _update = _e[_f], rest = __rest(_e, [typeof _f === "symbol" ? _f : _f + ""]);
|
|
182
198
|
d = rest;
|
|
183
199
|
}
|
|
@@ -398,6 +414,21 @@ const createPrismaMock = async (data = {}, pathToSchema, client = (0, jest_mock_
|
|
|
398
414
|
return shouldInclude;
|
|
399
415
|
});
|
|
400
416
|
}
|
|
417
|
+
if (args === null || args === void 0 ? void 0 : args.orderBy) {
|
|
418
|
+
const keys = Object.keys(args.orderBy);
|
|
419
|
+
res.sort((a, b) => {
|
|
420
|
+
for (const key of keys) {
|
|
421
|
+
const dir = args.orderBy[key];
|
|
422
|
+
if (a[key] > b[key]) {
|
|
423
|
+
return dir === "asc" ? 1 : -1;
|
|
424
|
+
}
|
|
425
|
+
else if (a[key] < b[key]) {
|
|
426
|
+
return dir === "asc" ? -1 : 1;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return 0;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
401
432
|
if (args === null || args === void 0 ? void 0 : args.select) {
|
|
402
433
|
return res.map(item => {
|
|
403
434
|
const newItem = {};
|