Answer the question
In order to leave comments, you need to log in
How to get user _id during registration (mongoose)?
Hello, I want to make sure that each user has their own referral link,
which will be equal to the _id of this user, but I can’t figure out how to do it, this is how I imagine it:
This is how the user scheme looks like (this is not a link, this is a spoiler)
const userSchema = new Schema({
login: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
},
reflink: {
type: String,
required: true
},
})
const user = new User({
login: login,
email: email,
password: password,
reflink: _id
})
await user.save()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question