express+mongoose写接口的时候,第二次请求报错

出现如下报错:

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

解决办法是将 mongoose.model 模型定义在请求接口外面,不能重复定义!

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