Home > Net >  passport file can't not read the copmae password fucntion from the schema file
passport file can't not read the copmae password fucntion from the schema file

Time:11-10

when i try to enter the correct password and email it gave me an error and the file crashes

here is my terminal error

enter image description here

and my passport file enter image description here

and the schema file enter image description here

CodePudding user response:

You are accessing the Instance method directly without creating a Schema Instance, if you want to access a method like this

Schema.compare 

You need to create a static method in Schema.

Example Static Method Creating :

// 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); 

If you want to read more please follow this link

  • Related