Thursday 1 June 2017

Sequelize validate throws [object object] error

I'm trying out Sequelize's built in validators. Model definition:

module.exports = function(sequelize, DataTypes) {
var Device = sequelize.define('Device', {
    model_name: {
      type: DataTypes.STRING,
      validate: {
        notNull: {
          args: true,
          msg: 'Model name needed'
        }
      }
    }
    ...

with bulkCreate

Device.bulkCreate(csvOutput, { validate: true })
  .then(function() {
    console.log('Records inserted into database')
  })
  .catch(function(err) {
    console.log('Error encountered: ' + err.message)
  })

I'm getting an error that is simply '[object Object]' and could not seem to figure out why.



via artze

No comments:

Post a Comment