generateQueryTableHelper method

void generateQueryTableHelper(
  1. String pathPackageLocal2dart
)

Implementation

void generateQueryTableHelper(String pathPackageLocal2dart) {
  final dir = join(pathPackageLocal2dart, 'lib', 'models');
  DirectoryHelper.createDir(dir);

  final Map queries = local2dart['query'] ?? {};

  queries.forEach((key, value) {
    if (value is! Map) return;
    value.forEach((queryName, query) {
      final Map columns = query['column'] ?? {};

      List<String> importForeign = [];
      List<String> constructor = [];
      List<String> constructorAssign = [];
      List<String> variables = [];
      List<String> toMap = [];
      List<String> fromMap = [];
      List<String> fromMapWithJoin = [];
      List<String> props = [];
      List<String> paramCopyWith = [];
      List<String> valueCopyWith = [];

      columnToList(
          columns: columns,
          tables: queries,
          tableName: queryName,
          foreigns: {},
          callback: (
            importForeignCallback,
            constructorCallback,
            constructorAssignCallback,
            variablesCallback,
            toMapCallback,
            fromMapCallback,
            fromMapWithJoinCallback,
            propsCallback,
            paramCopyWithCallback,
            valueCopyWithCallback,
          ) {
            importForeign = importForeignCallback;
            constructor = constructorCallback;
            constructorAssign = constructorAssignCallback;
            variables = variablesCallback;
            toMap = toMapCallback;
            fromMap = fromMapCallback;
            fromMapWithJoin = fromMapWithJoinCallback;
            props = propsCallback;
            paramCopyWith = paramCopyWithCallback;
            valueCopyWith = valueCopyWithCallback;
          });

      generateModel(
        path: join(dir, '${queryName.toString().snakeCase}_query.dart'),
        className: '${queryName.toString().pascalCase}Query',
        importForeign: importForeign,
        constructor: constructor,
        constructorAssign: constructorAssign,
        variables: variables,
        toMap: toMap,
        fromMap: fromMap,
        fromMapWithJoin: fromMapWithJoin,
        paramCopyWith: paramCopyWith,
        valueCopyWith: valueCopyWith,
        props: props,
      );
    });
  });
}