Im running into an issue where when I go to the terminal to display all doctors "db.doctors.find({})", I dont get any results. But when I display all hospitals with "db.hospitals.find({})", I get all of the hospital seeds. I've posted my seed and my model. What am I missing?
//DOCTOR SEED
Doctor.find({}).remove(function () {
Doctor.create({
"doctorId": 31816,
..
"hospitalId": 4994
},
{
"doctorId": 12547,
..
"hospitalId": 6665
} );
});
//HOSPITAL SEED
Hospital.find({}).remove(function () {
Hospital.create(
{
"address1": "2880 House",
"hospitalId": 4994,
//other fields
},
{
"address1": "100-4803 Road ave",
"hospitalId": 6665,
//other fields
})});
Model
var HospitalSchema = new Schema({
address1: String,
doctors: [{ type: Schema.Types.ObjectId, ref: 'Doctor'}],
hospitalId: Number,
//other fields
});
module.exports = mongoose.model('Hospital', HospitalSchema);
var DoctorSchema = new Schema({
doctorId: Number,
//other fields
branchId: {
type: Schema.Types.ObjectId,
ref: 'Hospital'
}
});
module.exports = mongoose.model('Doctor', DoctorSchema);