/
home
/
infinitibizsol
/
.trash
/
controllers.8
/
policy
/
File Upload :
llllll
Current File: /home/infinitibizsol/.trash/controllers.8/policy/policyForm.js
import db from "../../model/index"; import AppError from "../../utils/apiError"; import catchAsync from "../../utils/catchAsync"; import { successResponse, failedResponse } from "../../utils/responseFormat"; const index = catchAsync(async (req, res, next) => { const query = req.query; let allData = await db.PolicyForm.find(query); return successResponse(res, allData); }); const add = catchAsync(async (req, res, next) => { const policyForm = new db.PolicyForm(req.body); await policyForm.save(); return successResponse(res, policyForm, "PolicyForm saved successfully"); }); const edit = catchAsync(async (req, res, next) => { let result = await db.PolicyForm.findByIdAndUpdate( { _id: req.params.id }, { $set: req.body }, { new: true } ); if (!result) { return next(new AppError("No data found.", 404)); } return successResponse(res, result, "PolicyForm updated successfully"); }); const deleteData = catchAsync(async (req, res, next) => { let policyForm = await db.PolicyForm.findByIdAndDelete({ _id: req.params.id, }); if (!policyForm) { return next(new AppError("No data found.", 404)); } return successResponse(res, policyForm, "PolicyForm deleted successfully"); }); export default { index, add, edit, deleteData };
Copyright ©2k19 -
Hexid
|
Tex7ure