I am looking to create a database collection similar to
{username : "jack", password : "pass"}
for storing doctors' login information. I believe I can achieve this during signup by implementing the following code:
var Doctor = mongoose.model("doctor", authSchema);
module.exports = Doctor;
The code snippet above would generate a collection named doctor with the provided data from the form, as shown below.
app.post("/signup", function(req, res){
Doctor.create({username: req.body.username , password : req.body.password})
res.redirect("/login");
})
It might be beneficial to have separate collections for doctors and patients. This way, doctors can manage their profile information and add patients to their database. A key question is how to link these two collections. Considering that doctors will need to sign in using passport local and access only their own patient records, one approach could involve creating a "view patients" link that utilizes passport's req.user
to fetch all patients associated with that specific doctor. Is this the correct method to establish this relationship? As I navigate through this learning process independently, the concept of utilizing two collections is new to me, and I want to ensure I am heading in the right direction.