{"version":"1.0","type":"rich","title":"Gist cb0863f6e1b515510fa87520bd854996","description":"This example demonstrates how to automatically hash a user's password before saving it to a MongoDB database using Mongoose middleware. The code defines a `User` schema with email and password fields, then attaches a `pre('save')` hook that checks if the password was modified and applies bcrypt’s `hashSync` function with a salt factor of 10. It also includes a `comparePassword` method that uses `bcrypt.compare` to verify passwords. The example shows a test case where a new user is created and saved, logging the resulting bcrypt-hashed password.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-cb0863f6e1b515510fa87520bd854996?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}