Spaces:
Running
Running
fix(tools): make sure to remove toolid from assistant when deleting tool
Browse files
src/routes/tools/[toolId]/+page.server.ts
CHANGED
@@ -36,7 +36,7 @@ export const actions: Actions = {
|
|
36 |
|
37 |
await collections.tools.deleteOne({ _id: tool._id });
|
38 |
|
39 |
-
//
|
40 |
await collections.settings.updateMany(
|
41 |
{
|
42 |
tools: { $in: [tool._id.toString()] },
|
@@ -46,6 +46,16 @@ export const actions: Actions = {
|
|
46 |
}
|
47 |
);
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
redirect(302, `${base}/tools`);
|
50 |
},
|
51 |
report: async ({ request, params, locals, url }) => {
|
|
|
36 |
|
37 |
await collections.tools.deleteOne({ _id: tool._id });
|
38 |
|
39 |
+
// Remove the tool from all users' settings
|
40 |
await collections.settings.updateMany(
|
41 |
{
|
42 |
tools: { $in: [tool._id.toString()] },
|
|
|
46 |
}
|
47 |
);
|
48 |
|
49 |
+
// Remove the tool from all assistants
|
50 |
+
await collections.assistants.updateMany(
|
51 |
+
{
|
52 |
+
tools: { $in: [tool._id.toString()] },
|
53 |
+
},
|
54 |
+
{
|
55 |
+
$pull: { tools: tool._id.toString() },
|
56 |
+
}
|
57 |
+
);
|
58 |
+
|
59 |
redirect(302, `${base}/tools`);
|
60 |
},
|
61 |
report: async ({ request, params, locals, url }) => {
|