Insert multiple records in Sqflite

前端 未结 5 1812
花落未央
花落未央 2020-12-19 07:37

How to insert quickly multiple records in sqflite? The standard quickly method is:

await database.insert(table, object.toMap())
<
5条回答
  •  情话喂你
    2020-12-19 08:23

    You can use batch in such case.

    batch = db.batch();
    batch.insert('Test', {'name': 'item'});
    batch.update('Test', {'name': 'new_item'}, where: 'name = ?', whereArgs: ['item']);
    batch.delete('Test', where: 'name = ?', whereArgs: ['item']);
    results = await batch.commit();
    

    big batches,you can use await batch.commit(noResult: true);

提交回复
热议问题