Mongoose Schema hasn't been registered for model

前端 未结 17 888
猫巷女王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:33

    You should also check that you don't have dirty data in your database. I ended up with a document containing the lowercased version of the referenced model (user instead of User). This causes the error and is incredibly hard to track down.

    Easy to fix with a quick mongo query:

    db.model.updateMany({ approvedByKind: 'user' }, { $set: { approvedByKind: 'User' } })
    

提交回复
热议问题