1. How to insert the data from the values array into the database in bulk? The value obtained by
values is: values= [[1Jing 2pje 1pcr 00pr 418223] and the length of the array is uncertain, so the length here is 2. Thank you for guidance!
function insertData (data) {
// console.log(data);
// var events = [];
var values=[];
async.map(data,function(item,cb){
_getNewSN({
query:{category : "ProjectOID_" + item.ProjectOID},
success:function(sn){
var param=[parseInt(item.FunctionCode) ,
parseInt(item.StartRegister) ,
parseInt(item.Length) ,
item.Description ,
item.ProjectHardwareOID ,
sn.SN];
cb(null,param)
},
error : sender.error
});
},function(err,values){
console.log(values)
var sql = "insert into " +
"plcModbusTCPDB(FunctionCode,StartRegister," +
"Length,Description,ProjectHardwareOID," +
"DataID) values (?,?,?,?,?,?)";
yjDBService.exec({
sql:sql,
parameters : values,
success : sender.success,
error : sender.error
});
})-sharp-sharp-sharp
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)