Node.js TypeError:Pacient.getPacients不是仅针对一个对象的函数

Node.js TypeError:Pacient.getPacients不是仅针对一个对象的函数,node.js,mongodb,express,mongoose,mongoose-schema,Node.js,Mongodb,Express,Mongoose,Mongoose Schema,您好,我正在使用express和mongoDB创建一个NodeJSAPI。现在我有以下文件,app.js文件 var express = require('express'); var app = express(); var bodyParser = require('body-parser'); var mongoose = require('mongoose'); app.use(bodyParser.json()); Doctor = r

您好,我正在使用express和mongoDB创建一个NodeJSAPI。现在我有以下文件,app.js文件

    var express = require('express');
    var app = express();
    var bodyParser = require('body-parser');
    var mongoose = require('mongoose');
    app.use(bodyParser.json());

    Doctor = require('./Models/doctor');
    Pacient = require('./Models/pacient');

    // connect to mongoose
    mongoose.connect('mongodb://localhost/tfmehealth');
    var db = mongoose.connection;

    app.get('/', function(req,res){
    res.send('Please use /api/endpoint_name');
    });


    app.post('/api/signup',function(req,res){
    console.log(req.body);
    var pacientR = req.body;
    Pacient.addPacient(pacientR, function(err, pacient){
        if(err) {
            throw err;
        }

        res.json(pacient)
    });
    });
doctor.js文件

    var mongoose = require('mongoose');

//Doctor Schema

var doctorSchema = mongoose.Schema({
    name: {
    type:String
    },
    lastname1: {
    type:String
    },
    lastname2: {
    type:String
    },
    email: {
    type:String
    },
    password: {
    type:String
    },
    specialty: {
    type:String
    },
    dateOfBirth: {
    type:String
    }

});

var Doctor = module.exports = mongoose.model('Doctor', doctorSchema);

//Get doctors
module.exports.getDoctors = function(callback, limit) {
    Doctor.find().exec(callback);
}

//Get doctor by email
module.exports.getDoctorByEmail = function(emailid, callback) {
    Doctor.findOne(emailid).exec(callback);
}

//Get doctor by id
module.exports.getDoctorById = function(id, callback) {
    Doctor.findById(id).exec(callback);
}

//store doctor
module.exports.addDoctor = function(doctor, callback) {
    Doctor.create(doctor, callback);
}

//update doctor
module.exports.updateDoctor = function(id, doctor, options, callback) {
    var query = {_id:id};
    var update = {
        name: doctor.name,
        lastname1: doctor.lastname1,
        lastname2: doctor.lastname2,
        email: doctor.email,
        //password: doctor.password,
        specialty: doctor.specialty,
        dateOfBirth: doctor.dateOfBirth
    }
    Doctor.findOneAndUpdate(query, update, options, callback);
}
以及pacient.js文件

  var mongoose = require('mongoose');

//Pacient Schema

var pacientSchema = mongoose.Schema({
    name: {
    type:String
    },
    lastname1: {
    type:String
    },
    lastname2: {
    type:String
    },
    email: {
    type:String
    },
    password: {
    type:String
    },
    medicines: {
    type:String
    },
    allergies: {
    type:String
    },
    surgeries: {
    type:String
    },
    dateOfBirth: {
    type:String
    },
    weight: {
    type:String
    },
    height: {
    type:String
    },
    diseases: {
    type:String
    },
    comments: {
    type:String
    }
});

var Pacient = module.exports = mongoose.model('Pacient', pacientSchema);

module.exports.getPacients = function(allback) {
    Pacient.find.exec(callback);
}

//Get pacient by email
module.exports.getPacientByEmail = function(emailid, callback) {
    Pacient.findOne(emailid).exec(callback);
}

//Get pacient by id
module.exports.getPacientById = function(id, callback) {
    Pacient.findById(id).exec(callback);
}

//store pacient
module.exports.addPacient = function(pacient, callback) {
    Pacient.create(pacient, callback);
}

//update pacient
module.exports.updatePacient = function(id, pacient, options, callback) {
    var query = {_id:id};
    var update = {
        name: pacient.name,
        lastname1: pacient.lastname1,
        lastname2: pacient.lastname2,
        email: pacient.email,
        password: pacient.password,
        medicines: pacient.medicines,
        allergies: pacient.allergies,
        surgeries: pacient.surgeries,
        dateOfBirth: pacient.dateOfBirth,
        weight: pacient.weight,
        height: pacient.height,
        diseases: pacient.diseases,
        comments: pacient.comments
    }
    Pacient.findOneAndUpdate(query, update, options, callback);
}
doctor.js文件中的函数工作正常,但是pacient.js文件中的所有函数都会显示错误类型错误:X不是函数,我不知道pacient对象缺少什么,我认为它与doctor对象相同,但它不工作,有什么想法吗


谢谢

我想X已经定义好了。怎么定义?pacient.js文件中的所有函数都有不同的名称@Şüksefhamp请仔细查看。很抱歉,我在代码中没有看到任何函数两次。我已经测试了pacient.js文件中的所有函数,所有函数都正常工作,除了getPacients函数中存在键入错误,调用参数名称应该是错误的module.exports.getPacients=函数(回调){Pacient.find().exec(回调);}