mirror of https://github.com/AMT-Cheif/drift.git
add option
This commit is contained in:
parent
0af30cfb11
commit
3cd64901d6
|
@ -61,6 +61,10 @@ class DriftOptions {
|
|||
@JsonKey(name: 'generate_connect_constructor', defaultValue: false)
|
||||
final bool generateConnectConstructor;
|
||||
|
||||
/// Generate managers to assist with common database operations.
|
||||
@JsonKey(name: 'generate_manager', defaultValue: true)
|
||||
final bool generateManager;
|
||||
|
||||
@JsonKey(name: 'sqlite_modules', defaultValue: [])
|
||||
@Deprecated('Use effectiveModules instead')
|
||||
final List<SqlModule> modules;
|
||||
|
@ -128,6 +132,7 @@ class DriftOptions {
|
|||
this.useColumnNameAsJsonKeyWhenDefinedInMoorFile = true,
|
||||
this.useSqlColumnNameAsJsonKey = false,
|
||||
this.generateConnectConstructor = false,
|
||||
this.generateManager = true,
|
||||
this.dataClassToCompanions = true,
|
||||
this.generateMutableClasses = false,
|
||||
this.rawResultSetData = false,
|
||||
|
@ -156,6 +161,7 @@ class DriftOptions {
|
|||
required this.useColumnNameAsJsonKeyWhenDefinedInMoorFile,
|
||||
required this.useSqlColumnNameAsJsonKey,
|
||||
required this.generateConnectConstructor,
|
||||
required this.generateManager,
|
||||
required this.dataClassToCompanions,
|
||||
required this.generateMutableClasses,
|
||||
required this.rawResultSetData,
|
||||
|
|
|
@ -20,6 +20,7 @@ DriftOptions _$DriftOptionsFromJson(Map json) => $checkedCreate(
|
|||
'use_column_name_as_json_key_when_defined_in_moor_file',
|
||||
'use_sql_column_name_as_json_key',
|
||||
'generate_connect_constructor',
|
||||
'generate_manager',
|
||||
'sqlite_modules',
|
||||
'sqlite',
|
||||
'sql',
|
||||
|
@ -57,6 +58,8 @@ DriftOptions _$DriftOptionsFromJson(Map json) => $checkedCreate(
|
|||
'use_sql_column_name_as_json_key', (v) => v as bool? ?? false),
|
||||
generateConnectConstructor: $checkedConvert(
|
||||
'generate_connect_constructor', (v) => v as bool? ?? false),
|
||||
generateManager:
|
||||
$checkedConvert('generate_manager', (v) => v as bool? ?? true),
|
||||
dataClassToCompanions: $checkedConvert(
|
||||
'data_class_to_companions', (v) => v as bool? ?? true),
|
||||
generateMutableClasses:
|
||||
|
@ -116,6 +119,7 @@ DriftOptions _$DriftOptionsFromJson(Map json) => $checkedCreate(
|
|||
'use_column_name_as_json_key_when_defined_in_moor_file',
|
||||
'useSqlColumnNameAsJsonKey': 'use_sql_column_name_as_json_key',
|
||||
'generateConnectConstructor': 'generate_connect_constructor',
|
||||
'generateManager': 'generate_manager',
|
||||
'dataClassToCompanions': 'data_class_to_companions',
|
||||
'generateMutableClasses': 'mutable_classes',
|
||||
'rawResultSetData': 'raw_result_set_data',
|
||||
|
@ -149,6 +153,7 @@ Map<String, dynamic> _$DriftOptionsToJson(DriftOptions instance) =>
|
|||
instance.useColumnNameAsJsonKeyWhenDefinedInMoorFile,
|
||||
'use_sql_column_name_as_json_key': instance.useSqlColumnNameAsJsonKey,
|
||||
'generate_connect_constructor': instance.generateConnectConstructor,
|
||||
'generate_manager': instance.generateManager,
|
||||
'sqlite_modules':
|
||||
instance.modules.map((e) => _$SqlModuleEnumMap[e]!).toList(),
|
||||
'sqlite': instance.sqliteAnalysisOptions?.toJson(),
|
||||
|
|
|
@ -148,13 +148,16 @@ class DatabaseWriter {
|
|||
}
|
||||
}
|
||||
|
||||
final managerWriter = ManagerWriter(scope.child(), dbScope, dbClassName);
|
||||
for (var table in elements.whereType<DriftTable>()) {
|
||||
managerWriter.addTable(table);
|
||||
// Write the main database manager & all the managers for tables
|
||||
if (scope.options.generateManager) {
|
||||
final managerWriter = ManagerWriter(scope.child(), dbScope, dbClassName);
|
||||
for (var table in elements.whereType<DriftTable>()) {
|
||||
managerWriter.addTable(table);
|
||||
}
|
||||
managerWriter.write();
|
||||
// Add getter for the manager to the database class
|
||||
firstLeaf.writeln(managerWriter.managerGetter);
|
||||
}
|
||||
managerWriter.write();
|
||||
|
||||
firstLeaf.writeln(managerWriter.managerGetter);
|
||||
|
||||
// Write implementation for query methods
|
||||
for (final query in input.availableRegularQueries) {
|
||||
|
|
Loading…
Reference in New Issue