Express 在下次sailsjs服务器重置之前未检测到水线唯一验证

Express 在下次sailsjs服务器重置之前未检测到水线唯一验证,express,sails.js,waterline,Express,Sails.js,Waterline,我正在使用sails@beta. 我正在尝试创建以下几个房间模型(请参见定义),问题是我可以成功创建具有相同属性“name”的房间模型,尽管属性“name”具有唯一的验证 直到下次重新启动“sails”服务器时才检测到验证,然后我得到以下输出: C:\eMali_dev\server>sails lift info: Starting app... Express midleware for passport Waterline encountered a fatal error wh

我正在使用sails@beta.

我正在尝试创建以下几个房间模型(请参见定义),问题是我可以成功创建具有相同属性“name”的房间模型,尽管属性“name”具有唯一的验证

直到下次重新启动“sails”服务器时才检测到验证,然后我得到以下输出:

C:\eMali_dev\server>sails lift

info: Starting app...

Express midleware for passport
Waterline encountered a fatal error when trying to perform the `alter` auto-migration strategy.
In a couple of seconds, the data (cached in memory) will be logged to stdout.
(a failsafe put in place to preserve development data)

In the mean time, here's the error:

Error (E_UNKNOWN) :: Encountered an unexpected error:
MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1  dup key: { : "e1" }
Details:
{ error: 'E_UNKNOWN',
  summary: 'Encountered an unexpected error',
  status: 500,
  raw: 'MongoError: E11000 duplicate key error index: eMali_beta_dev.room.$name_1  dup key: { : "e1" }' }


================================
Data backup:
================================

[ { name: 'e1',
    center: '53471e2318b931dc1b69f3a8',
    min_age: 1,
    max_age: 6,
    createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    _id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióc' } },
  { name: 'e2',
    center: '53471e2318b931dc1b69f3a8',
    min_age: 1,
    max_age: 7,
    createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    _id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bióª' } },
  { name: 'e1',
    center: '53471e2318b931dc1b69f3a8',
    min_age: 1,
    max_age: 6,
    createdAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    updatedAt: Fri Apr 11 2014 00:41:39 GMT+0200 (W. Europe Summer Time),
    _id: { _bsontype: 'ObjectID', id: 'SG\u001e#\u001811Ü\u001bió«' } } ]
error: A hook (`orm`) failed to load!
房间型号:

module.exports = {

    schema: true,

    attributes: {

        name: {
            type: 'string',
            required: true,
            unique: true,
            minLength: 3
        },

        center: {
            model: 'center'
        },

        min_age: {
            type: 'integer',
            required: true
        },

        max_age: {
            type: 'integer',
            required: true
        }
    }
}

您需要将数据库从默认磁盘数据库更改为您选择的数据库。 我也面临类似的问题,将数据库从“磁盘”更改为“MongoDB”解决了我的问题。 默认数据库似乎无法实施唯一约束


我希望它能解决您的问题。

这是一个帆上的错误,已经修复。谢谢大家

它在以后的版本中被修复并再次损坏,它没有被修复。我很高兴听到我不是唯一一个有这个问题的人。让我们开始一场革命,把它修好!现在,您可以通过在Model.jsI中添加Model.find()check-in BeforeUpdate和BeforeCreate函数来添加一个变通方法检查。我希望我不必为了使模型验证工作而添加这种hack。