Q:

Bulk insertion on SQLite with ionic 3

I want to do a bulk insertion in ionic 3 I have this code it works but it's really slow 
 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");
    })
    }
  }

please help me with this

A:

You can do bulk operations with Ionic and SQLite like this:
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));

