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/177ee8fa56cfbaa8.js

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



const index = catchAsync(async (req, res, next) => {
  const query = req.query;
  let allData = await db.EmploymentInfo.find(query, {
    __v: 0,
    createdOn: 0,
    modifiedOn: 0,
  })
    .populate("user_id", ["_id", "first_name"])
    .exec();

  return successResponse(res, allData);
});

const add = catchAsync(async (req, res, next) => {
  const employmentInfo = new db.EmploymentInfo(req.body);
  await employmentInfo.save();
  return successResponse(
    res,
    employmentInfo,
    "employment-info saved successfully"
  );
});

const view = catchAsync(async (req, res, next) => {
  let result = await db.EmploymentInfo.findOne({ user_id: req.user._id });
  if (!result) {
    return next(new AppError("No data found.", 404));
  }
  return successResponse(res, result);
});

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

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

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

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