Open tankist opened 7 years ago
example for that: UserSeed.js
module.exports = [
{
"email": "test@test.com",
"password": "123",
},
];
models/User.js -> mongoose model
userSchema.pre('update', beforeSave);
userSchema.pre('save', beforeSave);
function beforeSave(next) {
if (this.isModified('password')) {
this.password = bcrypt.hashSync(this.password, SALT_ROUNDS);
}
return next();
}
Currently there is no possibility to exclude some fields from the find criteria and so sometimes not all existing records deleted.
I propose to modify seed process to give user ability to define excluded fields or to define criteria itself