【问题标题】:sails js - error when clean the collections in start upSails js - 在启动时清理集合时出错
【发布时间】:2015-07-16 15:44:23
【问题描述】:

在我的 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版,任何形式的帮助都将不胜感激。

【问题讨论】:

    标签: sails.js waterline


    【解决方案1】:

    同样的,当你对模型有错误时orm崩溃,至少你有错误,有时使用mysql你甚至没有错误

    【讨论】:

      【解决方案2】:

      问题是,在我的一些应用程序模型文件中,我已将以下内容添加到属性列表中。

      attributes: {
          _id: {
              type: 'string',
              unique: true
          }
      }
      

      由于我为属性添加了唯一的 true,因此当我尝试在启动时清理集合时会导致错误。有关此问题的更多信息,请访问Index already exists with different options error while using createIndex() in latest MongoDB java driver

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-06-13
        • 2014-07-14
        • 2020-04-11
        • 2018-12-07
        • 2021-07-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多