-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Oops, something went wrong.