express+mongoose寫接口的時候,第二次請求報錯

出現如下報錯:

(node:3488) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): OverwriteModelEr
ror: Cannot overwrite col_1 model once compiled.

解決辦法是將 mongoose.model 模型定義在請求接口外面,不能重複定義!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章