prisma-mock 0.0.26 → 0.0.27

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.
Files changed (2) hide show
  1. package/lib/index.js +7 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -409,8 +409,13 @@ const createPrismaMock = async (data = {}, pathToSchema, client = (0, jest_mock_
409
409
  const d = nestedUpdate(args, true, null);
410
410
  data = Object.assign(Object.assign({}, data), { [prop]: [...data[prop], d] });
411
411
  data = removeMultiFieldIds(model, data);
412
- // TODO: multi field ids
413
- return findOne(Object.assign({ where: { id: d.id } }, args));
412
+ let where = {};
413
+ for (const field of model.fields) {
414
+ if (field.default) {
415
+ where[field.name] = d[field.name];
416
+ }
417
+ }
418
+ return findOne(Object.assign({ where }, args));
414
419
  };
415
420
  const deleteMany = args => {
416
421
  const model = cachedSchema.datamodel.models.find(model => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-mock",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "Mock prisma for unit testing database",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",