Column.fromJson constructor

Column.fromJson(
  1. String colName,
  2. Map<String, dynamic> json,
  3. List<String> parentTableRequiredFields
)

Implementation

factory Column.fromJson(
  String colName,
  Map<String, dynamic> json,
  List<String> parentTableRequiredFields,
) {
  return Column(
    postgresFormat: json['format'],
    dbColName: colName,
    camelColName: snakeCasingToCamelCasing(colName),
    enumValues:
        json['enum'] != null ? List<String>.from(json['enum']) : <String>[],
    hasDefaultValue: json['default'] != null,
    description: json['description'],
    maxLength: json['maxLength'],
    isPrimaryKey: json['description']?.contains('<pk/>') ?? false,
    isSerialType: json['description']?.contains('[supadart:serial]') ?? false,
    isInRequiredColumn: parentTableRequiredFields.contains(colName),
  );
}