convertDatabaseToModelBase function
Future<SqfEntityModelBase>
convertDatabaseToModelBase(
- SqfEntityModelProvider model, {
- String? bundledDatabasePath,
- String? databasePath,
Create DB Model from DB
Implementation
Future<SqfEntityModelBase> convertDatabaseToModelBase(
SqfEntityModelProvider model,
{String? bundledDatabasePath,
String? databasePath}) async {
final bundledDbModel = SqfEntityProvider(model);
final tableList = await bundledDbModel
//.execDataTable('SELECT name,type FROM sqlite_master WHERE type=\'table\' or type=\'view\'');
.execDataTable(
'''SELECT name,type FROM sqlite_master WHERE type IN ('table','view') ${model.databaseTables != null && model.databaseTables!.isNotEmpty ? " AND name IN ('${model.databaseTables!.join('\',\'')}')" : ""}''');
print(
'SQFENTITY.convertDatabaseToModelBase---------------${tableList.length} tables and views found in ${model.bundledDatabasePath} database:');
printList(tableList);
final List<SqfEntityTableBase> tables =
await getObjects(tableList, bundledDbModel, model);
//for (var table in manyToManyTables) {
// tables.remove(table);
//}
return ConvertedModel()
..databaseName = model.databaseName
..modelName = toModelName(model.databaseName!.replaceAll('.', ''), '')
..databaseTables = tables
..password = model.password
..bundledDatabasePath = bundledDatabasePath
..databasePath = databasePath;
}