postgresqlsails.jswaterlinesails-postgresql

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


Im pretty new to sails, im trying to create an authentication schema in my postgresql db.

I have an user model

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'
    }
  }
}

and user registration/create controller

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"});
      }
    });
  }
}

Now when im using the default localDiskDb adapter, it works, the user is created by create method. When I changed default data source in datastores.js to

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

  }

I can see that tables are created in my database. But when I try to call the create method it returns error:

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

Im using these versions of sails packages:

    "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",

Does anyone have an idea?


Solution

  • Upgrade to

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

    solved it.