Mongoose Schema hasn't been registered for model

前端 未结 17 894
猫巷女王i
猫巷女王i 2020-11-27 15:00

I\'m learning the mean stack and when I try to start the server using

npm start

I get an exception saying that:

schema has         


        
17条回答
  •  广开言路
    2020-11-27 15:54

    If someone coudn't fix it with the approach of the correct answer (like me), try to look at the creation of the schema. I wrote the 'ref' as 'User', but the correct was 'user'.

    Wrong:

    createdBy: {
        type: Schema.Types.ObjectId,
        ref: 'User'
    }
    

    Correct:

    createdBy: {
        type: Schema.Types.ObjectId,
        ref: 'user'
    }
    

提交回复
热议问题