Node.js 使用mongoDB的Express模型中的一对多关系

Node.js 使用mongoDB的Express模型中的一对多关系,node.js,mongodb,express,model,Node.js,Mongodb,Express,Model,这是doctors.js模型: var mongoose = require('mongoose'), Schema = mongoose.Schema; var Patient = require('./patient.js'); var doctorSchema = mongoose.Schema({ firstName: String, lastName: String, qualifications: String, photo: Buffer, _patient

这是
doctors.js
模型:

var mongoose = require('mongoose'), Schema = mongoose.Schema;
var Patient = require('./patient.js');

var doctorSchema = mongoose.Schema({

  firstName: String,
  lastName: String,
  qualifications: String,
  photo: Buffer,
  _patients: [{ type: Schema.Types.ObjectId, ref: 'Patient' }]
});

var Doctor = mongoose.model('Doctor', doctorSchema);
module.exports = Doctor;
var mongoose = require('mongoose');
var Doctor = require('./doctor.js');

var patientSchema = mongoose.Schema({
  firstName: String,
  lastName: String,
  dob: String,
  gender: String,
  primaryDiagnosis: String,
  duration: String,
  _doctorIncharge: {type: Number, ref: 'Doctor'},
  hospitalNumber: String,
  photo: Buffer
});

var Patient = mongoose.model('Patient', patientSchema);
module.exports = Patient;
这是
patients.js
模型:

var mongoose = require('mongoose'), Schema = mongoose.Schema;
var Patient = require('./patient.js');

var doctorSchema = mongoose.Schema({

  firstName: String,
  lastName: String,
  qualifications: String,
  photo: Buffer,
  _patients: [{ type: Schema.Types.ObjectId, ref: 'Patient' }]
});

var Doctor = mongoose.model('Doctor', doctorSchema);
module.exports = Doctor;
var mongoose = require('mongoose');
var Doctor = require('./doctor.js');

var patientSchema = mongoose.Schema({
  firstName: String,
  lastName: String,
  dob: String,
  gender: String,
  primaryDiagnosis: String,
  duration: String,
  _doctorIncharge: {type: Number, ref: 'Doctor'},
  hospitalNumber: String,
  photo: Buffer
});

var Patient = mongoose.model('Patient', patientSchema);
module.exports = Patient;
这是让一对多关系发挥作用的方式吗