mern-boilerplate icon indicating copy to clipboard operation
mern-boilerplate copied to clipboard

Need to incorporate shortid for users

Open Tucker2015 opened this issue 3 years ago • 1 comments

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

Tucker2015 avatar Feb 01 '21 18:02 Tucker2015

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() },
  ...
});

djizco avatar Feb 04 '21 18:02 djizco