Sindbad~EG File Manager

Current Path : /home/infinitibizsol/.trash/node_modules.8/.cache/esm/
Upload File :
Current File : /home/infinitibizsol/.trash/node_modules.8/.cache/esm/0c6efd014f92af2d.js

let db,AppError,catchAsync,successResponse;_4f9‍.x([["default",()=>_4f9‍.o]]);_4f9‍.w("../../model/index",[["default",["db"],function(v){db=v}]]);_4f9‍.w("../../utils/apiError",[["default",["AppError"],function(v){AppError=v}]]);_4f9‍.w("../../utils/catchAsync",[["default",["catchAsync"],function(v){catchAsync=v}]]);_4f9‍.w("../../utils/responseFormat",[["successResponse",["successResponse"],function(v){successResponse=v}]]);




const index = catchAsync(async (req, res, next) => {
  const query = req.query;
  let allData = await db.PolicyAttachment.find(query);
  return successResponse(res, allData);
});

const add = catchAsync(async (req, res, next) => {
  const policyAttachment = new db.PolicyAttachment(req.body);
  await policyAttachment.save();
  return successResponse(
    res,
    policyAttachment,
    "PolicyAttachment saved successfully"
  );
});

const edit = catchAsync(async (req, res, next) => {
  let result = await db.PolicyAttachment.findByIdAndUpdate(
    { _id: req.params.id },
    { $set: req.body },
    { new: true }
  );
  if (!result) {
    return next(new AppError("No data found.", 404));
  }
  return successResponse(res, result, "PolicyAttachment updated successfully");
});

const deleteData = catchAsync(async (req, res, next) => {
  let policyAttachment = await db.PolicyAttachment.findByIdAndDelete({
    _id: req.params.id,
  });
  if (!policyAttachment) {
    return next(new AppError("No data found.", 404));
  }
  return successResponse(
    res,
    policyAttachment,
    "PolicyAttachment deleted successfully"
  );
});

_4f9‍.d({ index, add, edit, deleteData });

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists