Sails js - error clearing collections on startup

In my sail application, I edit the config / models.js file as follows to clear the database when the application is up.

  migrate: 'drop',
  connection: 'mongodb'

But when I try to run the application, it displays the following error.

A hook (`orm`) failed to load!
error: Error (E_UNKNOWN) :: Encountered an unexpected error
MongoError: Index with name: _id_ already exists with different options

I use sails version 0.10.5, any help would be appreciated.

+4
source share
2 answers

same here when you have a model error, orm crashes, at least you have an error, sometimes with mysql you don't even have an error

+1
source

The problem was in some of my application model files, which I added to the list of attributes.

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

true , , . createIndex() java- MongoDB

0

Source: https://habr.com/ru/post/1598255/


All Articles