在我的sails应用程序中,我编辑config/models.js文件,如下所示,以便在提升应用程序时清理数据库。
migrate: 'drop',
connection: 'mongodb'
但是,当我尝试运行应用程序时,它显示以下错误。
A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
MongoError: Index with name: _id_ already exists with different options
我使用的是sails版本0.10.5,任何类型的帮助都将不胜感激。
发布于 2015-07-17 07:45:13
这里也一样,当模型出错时,orm会崩溃,至少你会出错,有时在mysql中甚至不会出错
发布于 2015-07-18 12:21:22
问题是,在我的一些应用程序的模型文件中,我在属性列表中添加了以下内容。
attributes: {
_id: {
type: 'string',
unique: true
}
}
因为我已经为属性添加了唯一的true,所以当我试图在启动时清理集合时,它会导致一个错误。有关此问题的更多信息,请访问Index already exists with different options error while using createIndex() in latest MongoDB java driver
https://stackoverflow.com/questions/31458829
复制