Error: Consistency violation: A model references a datastore which cannot be found
Error: Consistency violation: A model references a datastore which cannot be found
我刚开始使用 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:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\validate-model-def.js:110:11)
at G:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\initialize.js:218:36
at arrayEach (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\node_modules\lodash\index.js:1289:13)
at Function.<anonymous> (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\node_modules\lodash\index.js:3345:13)
at Array.async.auto._normalizeModelDefs (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\initialize.js:216:11)
at listener (G:\projects\htdocs\warboard\node_modules\async\lib\async.js:605:42)
at G:\projects\htdocs\warboard\node_modules\async\lib\async.js:544:17
at _arrayEach (G:\projects\htdocs\warboard\node_modules\async\lib\async.js:85:13)
at Immediate.taskComplete [as _onImmediate] (G:\projects\htdocs\warboard\node_modules\async\lib\async.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
至:
connection: 'dbTest', // matches a key in connections.js
然后它将匹配您在 config/connections.js
文件中提供的密钥名称。
我刚开始使用 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:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\validate-model-def.js:110:11)
at G:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\initialize.js:218:36
at arrayEach (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\node_modules\lodash\index.js:1289:13)
at Function.<anonymous> (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\node_modules\lodash\index.js:3345:13)
at Array.async.auto._normalizeModelDefs (G:\projects\htdocs\warboard\node_modules\sails-hook-orm\lib\initialize.js:216:11)
at listener (G:\projects\htdocs\warboard\node_modules\async\lib\async.js:605:42)
at G:\projects\htdocs\warboard\node_modules\async\lib\async.js:544:17
at _arrayEach (G:\projects\htdocs\warboard\node_modules\async\lib\async.js:85:13)
at Immediate.taskComplete [as _onImmediate] (G:\projects\htdocs\warboard\node_modules\async\lib\async.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
至:
connection: 'dbTest', // matches a key in connections.js
然后它将匹配您在 config/connections.js
文件中提供的密钥名称。