We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 432ae44 commit aa5cb22Copy full SHA for aa5cb22
handler/factor.js
@@ -0,0 +1,20 @@
1
+import { AppError } from "./utils/app_error.js";
2
+import { catchAsyncError } from "./utils/catch_async_error.js";
3
+
4
+export const deleteOne = (model, name) => {
5
+ return catchAsyncError(async (req, res, next) => {
6
+ const { id } = req.params;
7
+ const document = await model.findByIdAndDelete(id, {
8
+ new: true,
9
+ });
10
11
+ let response = {};
12
+ response[name] = document;
13
+ console.log(response);
14
+ console.log({ ...response });
15
+ console.log(name);
16
+ document && res.status(201).json({ message: "success", ...response });
17
18
+ !document && next(new AppError(`${name} was not found`, 404));
19
20
+};
0 commit comments