Skip to content

Commit

Permalink
added approve_reject
Browse files Browse the repository at this point in the history
  • Loading branch information
digen21 committed Aug 8, 2022
1 parent d89d3c4 commit 7db4dad
Show file tree
Hide file tree
Showing 11 changed files with 2,724 additions and 0 deletions.
1 change: 1 addition & 0 deletions Approve_Reject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
60 changes: 60 additions & 0 deletions Approve_Reject/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const ejs = require('ejs');
const path = require('path');

app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(express.json())

mongoose.connect('mongodb://localhost:27017/dbc');

const dbcSchema = {
name: String,
email: String,
password: String,
status: String,
}

const dbcTable =require('./model/userSchema')


//Fetching Data From The Database
app.get('/', (req, res) => {
dbcTable.find({}, function(err, data) {
res.render('index', {
dataList: data
});
});
});

app.post('/approve', async(req, res) => {
const id = req.body.id;
const a = await dbcTable.updateOne({_id:id},{$set:{status: 'approved'}})
res.send(a);


})

app.post('/reject', async(req, res) => {
const id = req.body.id;
const a = await dbcTable.updateOne({_id:id},{$set:{status: 'rejected'}})
res.send(a);


})

app.get('/p',async(req, res) => {
dbcTable.find({}, function(err, data) {
res.render('patientpanel', {
dataList: data
});
});
})



app.listen(4000, function() {
console.log(`Server Is Running On http://localhost:${4000}`);
});
23 changes: 23 additions & 0 deletions Approve_Reject/model/userSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({


email:{
type: 'string',
required: true,
unique: true
},
password:{
type: 'string',
required: true
},
status:{
type:"string",
enum:["approved","pending","rejected"],
default: "pending"
}

});

module.exports =dbcTable= mongoose.model('users', userSchema);
Loading

0 comments on commit 7db4dad

Please sign in to comment.