import 'dart:convert';

import 'package:drift/drift.dart';

class StringListConverter extends TypeConverter<List<String>, String>{
  @override
  List<String> fromSql(String fromDb) {
    try {
      return (jsonDecode(fromDb) as List).cast<String>();
    } catch(e) {
      return [];
    }
  }

  @override
  String toSql(List<String> value) {
    return jsonEncode(value);
  }
  
}