I'm trying to insert data from an array in a table using async.each. It seems that the data are not inserted correctly. By using async.eachSeries it's working. It this normal?
I my (simplified) schema, I have two tables:
nodes
vendors
in nodes I have some fields and one vendor_id.
I'm doing something like that.
async.each(nodes, function(row, cb)
var extra = {vendor: row.vendor};
var node = {bla: row.bla};
nodeModel.create(node, function(err, items){
db.models.vendor.find({name: extra.vendor}).first(function(err, myVendor){
items.setVendor(myVendor, function(err){cb()});
});
});
By doing this, the vendor field is only set for the latest row inserted.
I'm trying to insert data from an array in a table using async.each. It seems that the data are not inserted correctly. By using async.eachSeries it's working. It this normal?
I my (simplified) schema, I have two tables:
in nodes I have some fields and one vendor_id.
I'm doing something like that.
By doing this, the vendor field is only set for the latest row inserted.