Skip to content

Commit

Permalink
chore: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 13, 2023
1 parent 0f2fa19 commit 6e0438e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,22 @@ export class CADSettingsController {
): Promise<APITypes.PutCADFeaturesData> {
const data = validateSchema(DISABLED_FEATURES_SCHEMA, body);

for (const feature of data.features) {
const createUpdateData = {
isEnabled: feature.isEnabled,
feature: feature.feature as Feature,
extraFields: JSON.stringify(feature.extraFields),
cadId: cad.id,
};

await prisma.cadFeature.upsert({
where: { feature: feature.feature as Feature },
create: createUpdateData,
update: createUpdateData,
});
}
await prisma.$transaction(
data.features.map((feature) => {
const createUpdateData = {
isEnabled: feature.isEnabled,
feature: feature.feature as Feature,
extraFields: JSON.stringify(feature.extraFields),
cadId: cad.id,
};

return prisma.cadFeature.upsert({
where: { feature: feature.feature as Feature },
create: createUpdateData,
update: createUpdateData,
});
}),
);

const updated = await prisma.cad.findUniqueOrThrow({
where: { id: cad.id },
Expand Down

0 comments on commit 6e0438e

Please sign in to comment.