护照文件无法从架构文件中读取罗盘密码功能
passport file can't not read the copmae password fucntion from the schema file
当我尝试输入正确的密码和电子邮件时
它给了我一个错误,文件崩溃了
这是我的终端错误
enter image description here
和我的护照档案
enter image description here
和模式文件
enter image description here
您正在直接访问 Instance 方法而不创建 Schema 实例,如果您想访问这样的方法
Schema.compare
您需要在 Schema 中创建一个静态方法。
示例静态方法创建:
// Assign a function to the "statics" object of our animalSchema
animalSchema.statics.findByName = function(name) {
return this.find({ name: new RegExp(name, 'i') });
};
// Or, equivalently, you can call `animalSchema.static()`.
animalSchema.static('findByBreed', function(breed) { return this.find({ breed }); });
const Animal = mongoose.model('Animal', animalSchema);
如果您想阅读更多内容,请关注此link
当我尝试输入正确的密码和电子邮件时 它给了我一个错误,文件崩溃了
这是我的终端错误
enter image description here
和我的护照档案 enter image description here
和模式文件 enter image description here
您正在直接访问 Instance 方法而不创建 Schema 实例,如果您想访问这样的方法
Schema.compare
您需要在 Schema 中创建一个静态方法。
示例静态方法创建:
// Assign a function to the "statics" object of our animalSchema
animalSchema.statics.findByName = function(name) {
return this.find({ name: new RegExp(name, 'i') });
};
// Or, equivalently, you can call `animalSchema.static()`.
animalSchema.static('findByBreed', function(breed) { return this.find({ breed }); });
const Animal = mongoose.model('Animal', animalSchema);
如果您想阅读更多内容,请关注此link