【问题标题】:Connecting to a postgresql database with Sails 1.0.0?使用 Sails 1.0.0 连接到 postgresql 数据库?
【发布时间】:2018-04-19 20:20:28
【问题描述】:

我刚刚决定将现有的 Sails 项目升级到 1.0.0,并设法完成了大部分升级过程,直到我尝试连接到数据库。尝试解除这是我收到的错误:

default 数据存储使用的适配器不兼容 当前版本的 Sails/Waterline。

适配器应该公开一个有效的adapterApiVersion

如果您使用的是 Sails 1.0 的测试版,请尝试:

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',据我了解,这意味着我的所有模型都应默认使用上述数据库。

到目前为止,升级过程非常简单。我想我在这里也遗漏了一些简单的东西。任何人都可以提供任何见解,我将不胜感激,也很乐意提供任何其他信息。

【问题讨论】:

    标签: node.js sails.js sails-postgresql


    【解决方案1】:

    原来项目正在寻找标记为 default 的数据存储。在datastore.jsmodel.js 中将名称更改为default 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2015-11-14
      • 2016-10-02
      • 2014-03-04
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多