NIT*_*SH 2 sqlite ionic-framework ionic3 angular
我想在 ionic 3 中进行批量插入我有这个代码它可以工作但它真的很慢
insertQuotation(value){
for(var i=0; i<=value.length; i++){
let data=[value[i].quotation_id,value[i].customer_name,value[i].product_name,value[i].price,value[i].services,value[i].response_time,value[i].created_time];
this.database.executeSql("insert into care_plan_quotation_history(care_plan_quotation_id,customer_name,product,price,services,response_time,created_time) values(?,?,?,?,?,?,?)",data)
.then(data=>{
return data;
},err=>{
alert("error");
})
}
}
Run Code Online (Sandbox Code Playgroud)
请在这件事上给予我帮助
您可以像这样使用 Ionic 和 SQLite 进行批量操作:
let insertRows = [];
items.forEach(item => {
insertRows.push([
"INSERT INTO items (id, type, date, message) VALUES (?, ?, ?, ?)",
[item.id, item.type, item.date, item.message]
]);
});
this.database.sqlBatch(insertRows).then((result) => {
console.info("Inserted items");
}).catch(e => console.log(e));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1413 次 |
| 最近记录: |