Shift Update Done, will add password next

This commit is contained in:
Mosiur Rahman
2024-11-28 02:48:11 +06:00
parent b1d976f1fc
commit 8cc71e3ab4
7 changed files with 76 additions and 17 deletions

View File

@@ -81,12 +81,12 @@ app.get("/", (req,res)=>{
})
app.get("/api/backup", async (req,res)=>{
const allBackup = await BackupModel.find({ deleted: { $ne: true} }).sort({ projectName: 'asc' })
const allBackup = await BackupModel.find({}).sort({ projectName: 'asc' })
res.send(allBackup)
})
app.get("/api/update", async (req,res)=>{
const allUpdate = await UpdateModel.find({}).sort({ Date: 'asc' })
const allUpdate = await UpdateModel.find({ deleted: { $ne: true} }).sort({ Date: 'asc' })
res.status(200).send(allUpdate);
})
@@ -114,13 +114,19 @@ app.post("/api/update/add", async (req,res)=>{
app.post("/api/update/complete", async(req,res)=>{
const id = req.body.id;
const status = req.body.Status;
const update = await BackupModel.findOneAndUpdate({_id: id},{ Status: status })
const update = await UpdateModel.findOneAndUpdate({_id: id},{ Status: status })
console.log(update)
if (update) {
res.send(update)
}
})
app.post("/api/update/delete", async(req,res)=>{
const id = req.body.id;
console.log(id)
const deleteTask = await UpdateModel.findOneAndUpdate({_id: id},{deleted: true}).then(()=>res.status(201).json({message: "Deleted Successfully"})).catch((err)=>res.status(500).send(err))
})
const PORT = 3000;
app.listen(PORT,()=>{