nodejs使用mongoose-encryption加密数据

c2e8gylq  于 11个月前  发布在  Go
关注(0)|答案(1)|浏览(125)

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

"C:\Users\user\OneDrive\old Desktop\web developer\WebDevelopment\Secrets - Starting Code\node_modules\mongoose-encrypt\lib\index.js:123
    paths.forEach(function(path) {^

TypeError: Cannot read property 'forEach' of undefined"

字符串
这是加密的代码

const usersSchema = new mongoose.Schema({
    email: String,
    password: String
});

const secret = "Thisisourlittilesecret";
usersSchema.plugin(encrypt, { secret: secret, encryptedFields: ['password'] });

const User = mongoose.model("User", usersSchema);

f1tvaqid

f1tvaqid1#

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

相关问题