createModelDatabase method

String createModelDatabase()

Implementation

String createModelDatabase() {
  _m.modelName = toModelName(_m.modelName, 'MyDbModel');
  return '''
// ignore_for_file: non_constant_identifier_names

//  These classes was generated by SqfEntity
//  Copyright (c) 2019, All rights reserved. Use of this source code is governed by a
//  Apache license that can be found in the LICENSE file.

//  To use these SqfEntity classes do following:
//  - import model.dart into where to use
//  - start typing ex:${_m.databaseTables!.isNotEmpty ? _m.databaseTables![0].modelName : ''}.select()... (add a few filters with fluent methods)...(add orderBy/orderBydesc if you want)...
//  - and then just put end of filters / or end of only select()  toSingle() / or toList()
//  - you can select one or return List<yourObject> by your filters and orders
//  - also you can batch update or batch delete by using delete/update methods instead of tosingle/tolist methods
//    Enjoy.. Huseyin Tokpunar

${_m.ignoreForFile != null ? '// ignore_for_file: ${_m.ignoreForFile!.join(', ')}' : ''}
$__createModelTables

$__createModelSequences

// BEGIN DATABASE MODEL
class ${_m.modelName} extends SqfEntityModelProvider {
${_m.modelName}() {
  databaseName = $_dbName;
  $_dbPassword $_dbVersion
  preSaveAction = ${_m.instanceName}.preSaveAction;
  logFunction = ${_m.instanceName}.logFunction;
  $__tableList
  $__sequenceList
  bundledDatabasePath =
      $_bundledDbName; //'assets/sample.db'; // This value is optional. When bundledDatabasePath is empty then EntityBase creats a new database when initializing the database
  $_databasePath
}
Map<String, dynamic> getControllers() {
  final controllers= <String, dynamic>{};
  ${controllers().toString()}
  return controllers;
}
}
// END DATABASE MODEL

''';
}