Hassan2bit

Home Blogs contact portfolio

  • 08 Dec, 2025 *

a simple documentation on hashing password before saving into db

  • A user schema model has been defined, using mongoose, it looks something like this:
const userSchema = new mongoose.Schema({
email: {
type: String,
required: true,
unique: true,
minlength: 4,
lowercase: true,
},
username: {
type: String,
required: true,
unique: true,
minlength: 4,
trim: true,
},
password: {
type: String,
required: true,
minlength: 6,
},

createdAt: {
type: Date,
default: Date.now,
},

role: {
default: "student",
enum: ["student", "admin"],
type: String...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help