Sto scrivendo il resto utilizzando il nodo, sequelize come ORM per mySQL. Sto utilizzando la funzione bulkCreate per creare record in blocco. Ma in risposta sta restituendo null per il valore della chiave primaria.Sequenziare bulkCreate() restituisce il valore NULL per la chiave primaria
Modello
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 Crea operazione:
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);
})
risposta:
[
{
"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"
}
]
Ma solo in postgres e mssql –