mysql - Sequelize bulkCreate() returns NULL value for primary key -


i writing rest using node, sequelize orm mysql. using bulkcreate function create record in bulk. in response returning null primary key value.

model

sequelize.define('category', {     cat_id:{         type:datatypes.integer,         field:'cat_id',         primarykey: true,         autoincrement: true,         unique:true     },     cat_name:{         type: datatypes.string,         field: 'cat_name',         defaultvalue:null     } }); 

bulk create operation :

var data = [         {             'cat_name':'fashion'         },         {             'cat_name':'food'         }     ];      orm.models.category.bulkcreate(data)     .then(function(response){         res.json(response);     })     .catch(function(error){         res.json(error);     }) 

response :

[   {     "cat_id": null,     "cat_name": "fashion",     "created_at": "2016-01-29t07:39:50.000z",     "updated_at": "2016-01-29t07:39:50.000z"   },   {     "cat_id": null,     "cat_name": "food",     "created_at": "2016-01-29t07:39:50.000z",     "updated_at": "2016-01-29t07:39:50.000z"   } ] 

tested in mysql:

model.bulkcreate(values, { individualhooks: true })


Comments