cloneTable method

Future<void> cloneTable(
  1. int table_id,
  2. DbTransaction importDatabase,
  3. DbTransaction exportDatabase
)

Implementation

Future<void> cloneTable(int table_id, DbTransaction importDatabase, DbTransaction exportDatabase) async {
  if(importDatabase==null) throw ArgumentError("importDatabase must not be null");
  if(exportDatabase==null) throw ArgumentError("exportDatabase must not be null");
  AbstractDao importDao = GenericDao(smd, importDatabase);
  await importDao.init(table_id: table_id);
  AbstractDao exportDao = GenericDao(smd, exportDatabase);
  await exportDao.init(table_id: table_id);

  FieldData fieldData=smd.getTableByTableId(table_id).getSelectFieldData(table_id);
  RawTableData rtd=await importDao.select(fieldData, WhereData());
  List<RawRowData> list=rtd.getRawRows();
  list.forEach((RawRowData rrd) async {
    await exportDao.insert(rrd.getFieldData(field_table_id: table_id));
  });
}