For example, the following schemes are in the following folders
cr/user
lms/content
this is the schema content
user: {
type: Schema.Types.ObjectId,
ref: 'cr/user'
}
How can I reference user from the schema content?
because if I use it like this I get an error "Schema hasn't been registered for model"
You are defining the reference wrong; This is not the path of the model , it is the name you give it when exporting it using
mongoose.model
.Example
If you have exported the model
user
as follows:So the reference should be
User
: