加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sails-postgresql AdapterError:数据库适配器出现意外错误:没

发布时间:2020-12-13 18:11:01 所属栏目:百科 来源:网络整理
导读:我对sails很新,我试图在 postgresql db中创建一个身份验证模式. 我有一个用户模型 module.exports = { attributes: { firstName: { type: 'string' },lastName: { type: 'string' },email: { type: 'string',required: true,unique: true },password: { type
我对sails很新,我试图在 postgresql db中创建一个身份验证模式.

我有一个用户模型

module.exports = {
  attributes: {
    firstName: {
      type: 'string'
    },lastName: {
      type: 'string'
    },email: {
      type: 'string',required: true,unique: true
    },password: {
      type: 'string',required: true
    },authTokens: {
      collection: 'authToken',via: 'owner'
    }
  }
}

和用户注册/创建控制器

module.exports = {

  create: function (req,res) {
    sails.log.info("Message to be logged");
    User.create(
      {
        email: req.body.email,firstName: req.body.firstName,lastName: req.body.lastName,password: req.body.password
      }
    ).exec(function (err) {
      if (err) {
        return res.status(400).send({err: err});
      } else {
        return res.status(200).send({message: "it is okay"});
      }
    });
  }
}

现在当我使用默认的localDiskDb适配器时,它工作,用户是由create方法创建的.当我将datastores.js中的默认数据源更改为

default: {
    adapter: 'sails-postgresql',host: 'mydbserver.rds.amazonaws.com',user: 'myDbRoot',password: 'pass',database: 'myDbName'

  }

我可以看到表是在我的数据库中创建的.但是当我尝试调用create方法时,它返回错误:

AdapterError: Unexpected error from database adapter: there is no
parameter $1

我使用这些版本的帆包:

"sails": "^1.0.0-30","sails-hook-grunt": "^1.0.4","sails-hook-orm": "^2.0.0-0","sails-hook-sockets": "^1.0.1","sails-postgresql": "1.0.0-1",

有没有人有想法?

升级到
"sails-hook-orm": "^2.0.0-17","sails-postgresql": "1.0.0-10",

解决了它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读