nodejs使用mongoose-encryption加密数据

c2e8gylq  于 2024-01-08  发布在  Go
关注(0)|答案(1)|浏览(209)

我尝试使用nodejs的mongoose-encryption来加密新用户的密码,但我得到了错误

  1. "C:\Users\user\OneDrive\old Desktop\web developer\WebDevelopment\Secrets - Starting Code\node_modules\mongoose-encrypt\lib\index.js:123
  2. paths.forEach(function(path) {^
  3. TypeError: Cannot read property 'forEach' of undefined"

字符串
这是加密的代码

  1. const usersSchema = new mongoose.Schema({
  2. email: String,
  3. password: String
  4. });
  5. const secret = "Thisisourlittilesecret";
  6. usersSchema.plugin(encrypt, { secret: secret, encryptedFields: ['password'] });
  7. const User = mongoose.model("User", usersSchema);

f1tvaqid

f1tvaqid1#

我也有同样的问题
原来我导入了'mongoose-encrypt'而不是'mongoose-encryption'

相关问题