Closed sarmancoderr closed 1 year ago
@sarmancoderr great idea. thanks
we can use it like
import { defineMongooseModel } from '#nuxt/mongoose'
export const UserSchema = defineMongooseModel({
name: 'User',
schema: {
email: {
type: 'string',
required: true,
unique: false,
},
password: {
type: 'string',
required: true,
},
},
hooks(schema) {
schema.pre('save', function (this, next) {
this.password = `hash.${this.password}}`
next()
})
},
})
thanks for the idea again.
Here I would like to have a way in wich i could have the ability to define a pre save hook to crypt the password, please consider this