djizco / mern-boilerplate

A Full MERN Stack Boilerplate for Web Apps including a local authentication system. Uses React, Express.js, MongoDB, Redux, Passport.js, Webpack, Testing, and more.
MIT License
266 stars 94 forks source link

Need to incorporate shortid for users #5

Open Tucker2015 opened 3 years ago

Tucker2015 commented 3 years ago

Not a bug. But how would I go about adding shortid to the mongodb. I need my users to have a stream key for my site which is generated on registration.

Bit of a beginner with Mern stack but willing to learn :)

I have this working in my site now but this looks like a better user profile option for me.

Thanks

djizco commented 3 years ago

All you would need to do is add a "stream_key" field to your userSchema when you are creating a new user.

const userSchema = new Schema({
  ...
  stream_key: { type: String, maxlength: 36, default: uuid.v4() },
  ...
});