Node.js Mongoose函数返回null

Node.js Mongoose函数返回null,node.js,mongodb,express,mongoose-populate,Node.js,Mongodb,Express,Mongoose Populate,我已经创建了通过输入电话号码获取患者数据的路线。我正在将phonenumber作为参数传递到URl中。findOne&populate方法用于从集合中获取文档,但该方法返回“null”。我是javascript初学者,因此无法发现错误。请帮忙做同样的事情 // @ route GET api/patient/:patientId // @ desc Get patient by patientId // @ access Private router.get('/patient/:pho

我已经创建了通过输入电话号码获取患者数据的路线。我正在将phonenumber作为参数传递到URl中。findOne&populate方法用于从集合中获取文档,但该方法返回“null”。我是javascript初学者,因此无法发现错误。请帮忙做同样的事情

// @ route  GET api/patient/:patientId
// @ desc   Get patient by patientId
// @ access Private

router.get('/patient/:phonenumber', auth, async (req, res) => {
    try {
      const patient_profile = await Patient.findOne({

        patient: req.params.phonenumber

      }).populate('patient',['name','phonenumber']);
      console.log(patient_profile);
      if (!patient_profile) return res.status(400).json({ msg: 'Patient not found' });

      res.json(patient_profile);    
    } catch (err) {
      console.error(err.message);
      if (err.kind == 'ObjectId') {
        return res.status(400).json({ msg: 'Profile not found' });
      }
      res.status(500).send('Server Error');
    }
  });

module.exports=router;
const mongoose= require('mongoose');
autoIncrement = require('mongoose-auto-increment');
const config =require('config');
const db=config.get('mongoURI');

//var connection = mongoose.createConnection(db);

//autoIncrement.initialize(connection);

const PatientSchema = new mongoose.Schema({
    name:{
        type:String,
        required: true
    },
    phonenumber:{
        type:Number,
        required:true
    },
    date: {
        type: Date,
        default: Date.now
    },
    slider_1:{
        type:Number,
        required: true
    },
    slider_2:{
        type:Number,
        required:true
    },
    slider_3:{
        type:Number,
        required:true
    }

});
//PatientSchema.plugin(autoIncrement.plugin, {
  //  model:'Patient',
   // field:'patientId',
   // startAt:1,
   // incrementBy:1
//});
module.exports=SystemUser=mongoose.model('patient',PatientSchema);