5

I am using sequelize in my application. I have postgres as underlying database. But when I tried to save instances I got following error

[error: missing dimension value]

I have the following model

module.exports = function(sequelize, DataTypes) {
  var Mymodel = sequelize.define('Mymodel', {
        id: {type : DataTypes.INTEGER, autoIncrement : true, primaryKey: true},
        title: {
          type: DataTypes.STRING(128),
          validate: {
            notNull: true,
            notEmpty: true
          }
        },
        tags: DataTypes.ARRAY(DataTypes.TEXT)
      });
  return Mymodel;
}

I am sending http post request as

{
"title":"Test challenge",
  "tags" : "['JAVA','REST','API']"
}

I am saving object like this

Mymodel.create(model).success(function(model) {
    callback(null, challenge);
  }).error(function(err) {
    callback(err, null);
  });

1 Answer 1

4

I tried sending over your model object as you stated and did get the error SequelizeValidationError: "['JAVA','REST','API']" is not a valid array. Perhaps you got a different error on an older version of Sequelize. Then, I made sure the tags value was a JavaScript array instead of a string and it worked.

Mymodel.create({ 
  title: 'Test challenge', 
  tags: ['JAVA','REST','API']
}).then(function() {});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.