Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prisma-mock

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-mock - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

128

lib/index.js

@@ -110,7 +110,7 @@ "use strict";

const otherIdField = joinmodel?.fields.find((f) => f.isId);
const items = manyToManyData[field.relationName]?.filter(subitem => subitem[otherfield.type][idField] === item[idField]);
const items = manyToManyData[field.relationName]
?.filter(subitem => subitem[otherfield.type]?.[idField] === item[idField]);
if (!items?.length) {
return null;
}
// Many-to-many
return {

@@ -227,5 +227,5 @@ [otherIdField.name]: { in: items.map(subitem => (subitem[field.type][otherIdField.name])) }

const keyToMatch = Object.keys(connect)[0];
if (field.relationToFields.length > 0) {
const keyToGet = field.relationToFields[0];
const targetKey = field.relationFromFields[0];
const keyToGet = field.relationToFields[0];
const targetKey = field.relationFromFields[0];
if (keyToGet && targetKey) {
let connectionValue = connect[keyToGet];

@@ -242,6 +242,8 @@ if (keyToMatch !== keyToGet) {

}
d = {
...rest,
[targetKey]: connectionValue,
};
if (targetKey) {
d = {
...rest,
[targetKey]: connectionValue,
};
}
}

@@ -253,19 +255,10 @@ else {

});
const inverse = otherModel.fields.find((otherField) => field.relationName === otherField.relationName);
const targetKey = inverse.relationToFields[0];
const otherField = otherModel.fields.find((otherField) => field.relationName === otherField.relationName);
const delegate = Delegate(getCamelCase(otherModel.name), otherModel);
if (!targetKey) {
const a = manyToManyData[field.relationName] = manyToManyData[field.relationName] || [];
a.push({
[field.type]: delegate.findOne({
where: connect
}),
[inverse.type]: d
});
}
else {
if (!targetKey && !keyToGet) {
const targetKey = otherField.relationToFields[0];
delegate.update({
where: connect,
data: {
[getCamelCase(inverse.name)]: {
[getCamelCase(otherField.name)]: {
connect: {

@@ -278,2 +271,11 @@ [targetKey]: d[targetKey],

}
else {
const a = manyToManyData[field.relationName] = manyToManyData[field.relationName] || [];
a.push({
[field.type]: delegate.findOne({
where: connect
}),
[otherField.type]: d
});
}
}

@@ -314,4 +316,5 @@ });

});
let createdItems = [];
if (c.createMany) {
delegate.createMany({
createdItems = delegate.createMany({
...c.createMany,

@@ -323,3 +326,3 @@ data: c.createMany.data.map(map),

if (Array.isArray(c.create)) {
delegate.createMany({
createdItems = delegate.createMany({
...c.create,

@@ -330,8 +333,18 @@ data: c.create.map(map),

else {
delegate.create({
...create.create,
data: map(create.create),
});
createdItems = [delegate.create({
...create.create,
data: map(create.create),
})];
}
}
const targetKey = joinfield.relationFromFields[0];
if (!targetKey) {
const a = manyToManyData[field.relationName] = manyToManyData[field.relationName] || [];
createdItems.forEach((item) => {
a.push({
[field.type]: item,
[joinfield.type]: d
});
});
}
}

@@ -359,6 +372,9 @@ }

const item = findOne(args);
delegate.update({
data: c.update,
where: getFieldRelationshipWhere(item, field, model),
});
const where = getFieldRelationshipWhere(item, field, model);
if (where) {
delegate.update({
data: c.update,
where,
});
}
}

@@ -526,2 +542,6 @@ }

const delegate = Delegate(getCamelCase(childName), submodel);
const joinWhere = getFieldRelationshipWhere(item, info, submodel);
if (!joinWhere) {
return false;
}
const res = delegate.findMany({

@@ -531,3 +551,3 @@ where: {

childWhere,
getFieldRelationshipWhere(item, info, submodel)
joinWhere
]

@@ -542,4 +562,7 @@ }

// )
const where = getFieldRelationshipWhere(item, info, model);
if (!where)
return false;
const all = delegate.findMany({
where: getFieldRelationshipWhere(item, info, model),
where,
});

@@ -549,3 +572,3 @@ return res.length === all.length;

else if (filter.some) {
return res.length > 0; //?
return res.length > 0;
}

@@ -814,15 +837,24 @@ else if (filter.none) {

let subArgs = obj[key] === true ? {} : obj[key];
subArgs = {
...subArgs,
where: {
...subArgs.where,
...getFieldRelationshipWhere(item, schema, model),
},
};
if (schema.isList) {
// Add relation
newItem = {
...newItem,
[key]: delegate._findMany(subArgs),
const joinWhere = getFieldRelationshipWhere(item, schema, model);
if (joinWhere) {
subArgs = {
...subArgs,
where: {
...subArgs.where,
...joinWhere,
},
};
if (schema.isList) {
// Add relation
newItem = {
...newItem,
[key]: delegate._findMany(subArgs),
};
}
else {
newItem = {
...newItem,
[key]: delegate._findMany(subArgs)?.[0] || null,
};
}
}

@@ -832,3 +864,3 @@ else {

...newItem,
[key]: delegate._findMany(subArgs)?.[0] || null,
[key]: [],
};

@@ -835,0 +867,0 @@ }

{
"name": "prisma-mock",
"version": "0.5.0",
"version": "0.5.1",
"description": "Mock prisma for unit testing database",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc