我刚刚决定将现有的 Sails 项目升级到 1.0.0,并设法完成了大部分升级过程,直到我尝试连接到数据库。尝试解除这是我收到的错误:
数据存储使用的适配器
default
与当前版本的 Sails/Waterline 不兼容。适配器应该公开一个有效的
adapterApiVersion
.如果您使用的是 Sails 1.0 的 beta 版本,请尝试:
npm install --savesails-disk@beta
我的datastores.js
文件包含以下内容:
module.exports.datastores = {
// In previous versions, datastores (then called 'connections') would only be loaded
// if a model was actually using them. Starting with Sails 1.0, _all_ configured
// datastores will be loaded, regardless of use. So we'll only include datastores in
// this file that were actually being used. Your original `connections` config is
// still available as `config/connections-old.js.txt`.
'developmentPostgres': {
adapter: require('sails-postgresql'),
url: process.env.postgresHost,
user: process.env.postgresUser,
password: process.env.postgresPassword,
database: process.env.postgresDatabase
}
};
其中所有值都作为环境变量提供。"sails-postgresql": "^1.0.0"
安装并保存在package.json
models.js
还包含以下行:datastore: 'developmentPostgres'
,据我了解,这意味着我的所有模型都应默认使用上述数据库。
到目前为止,升级过程非常简单。我想我在这里也遗漏了一些简单的东西。我将不胜感激任何人可以提供的任何见解,并且也很乐意提供任何其他信息。