错误:违反一致性:一个模型引用一个找不到的数据存储



我是使用SailsJS的新手,而且我正在使用mongodb来连接数据库。我尝试使用Robo 3T来确保我的连接有效,并检查模型是否在其中。但是,当我尝试使用sails lift举重时,我遇到了此错误:

error: A hook (`orm`) failed to load!
error:
error: Error: Consistency violation: A model (`calendar`) references a datastore which cannot be found (`warboard-test`).  If this
 model definition has an explicit `connection` property, check that it is spelled correctly.  If not, check your default `connecti
on` (usually located in `config/models.js`).  Finally, check that this connection (`warboard-test`) is valid as per http://sailsjs
.org/documentation/reference/configuration/sails-config-connections.
    at validateModelDef (G:projectshtdocswarboardnode_modulessails-hook-ormlibvalidate-model-def.js:110:11)
    at G:projectshtdocswarboardnode_modulessails-hook-ormlibinitialize.js:218:36
    at arrayEach (G:projectshtdocswarboardnode_modulessails-hook-ormnode_moduleslodashindex.js:1289:13)
    at Function.<anonymous> (G:projectshtdocswarboardnode_modulessails-hook-ormnode_moduleslodashindex.js:3345:13)
    at Array.async.auto._normalizeModelDefs (G:projectshtdocswarboardnode_modulessails-hook-ormlibinitialize.js:216:11)
    at listener (G:projectshtdocswarboardnode_modulesasynclibasync.js:605:42)
    at G:projectshtdocswarboardnode_modulesasynclibasync.js:544:17
    at _arrayEach (G:projectshtdocswarboardnode_modulesasynclibasync.js:85:13)
    at Immediate.taskComplete [as _onImmediate] (G:projectshtdocswarboardnode_modulesasynclibasync.js:543:13)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
error: Could not load Sails app.
error:
error: Tips:
error:   First, take a look at the error message above.
error:   Check that you're using the latest stable version of Sails.
error:   Have a question or need help?  (http://sailsjs.com/support)

我很确定我有一个日历模型,并且它通过gui在我的mongodb上存在。

这是我的config/connections.js

module.exports.connections = {
localDiskDb: {
  adapter: 'sails-disk'
},
dbTest: {
    adapter: 'sails-mongo',
    url: 'mongodb://user:password@host:port/db?replicaSet=rs-ds117073',
    socketOptions: {
      keepAlive: 1000,
      connectTimeoutMS: 60000
    }
  }
};

我的config/models.js

module.exports.models = {
 connection: 'db-test',
 migrate: 'alter',
 migrations: true,
 version: 3
};

帆:1.0.0-46节点:8.9.4

有人遇到此错误吗?

预先感谢!

您必须从:

中更改config/models.js中的行
connection: 'db-test', // no match in connections.js

to:

connection: 'dbTest', // matches a key in connections.js

然后它将与您在config/connections.js文件中给出的密钥名称匹配。

相关内容

最新更新