La convalida univoca del waterline non è stata rilevata fino al ripristino del server successivo Sailsjs

StackOverflow https://stackoverflow.com//questions/23000494

  •  20-12-2019
  •  | 
  •  

Domanda

Sto usando le vele @ beta.

Sto cercando di creare diversi modelli di stanza (vedi definizione) Di seguito, il problema è che posso creare con successo modelli di stanza con lo stesso attributo 'nome', sebbene attributo 'nome' ha una convalida unica.

La convalida non viene rilevata fino al riavvio successivo del server 'Vele' , quindi ottengo questa uscita:

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!
.

Modello di camera:

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
        }
    }
}
.

È stato utile?

Soluzione

Questo è stato un bug nelle vele ed è stato risolto.Grazie a tutti

Altri suggerimenti

È necessario modificare il database dal database del disco predefinito a un database di tua scelta. Stavo affrontando un problema simile e cambiando il database da "disco" a "mongodb" risolto il mio problema. Sembra che il database predefinito non sia in grado di far rispettare un vincolo unico.

Spero che risolva il tuo problema.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top