[StreamChatPersistence] Add initial implementation
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:moor/moor.dart';
|
||||
|
||||
///
|
||||
class MapConverter<T> extends TypeConverter<Map<String, T>, String> {
|
||||
@override
|
||||
Map<String, T> mapToDart(fromDb) {
|
||||
if (fromDb == null) {
|
||||
return null;
|
||||
}
|
||||
return Map<String, T>.from(jsonDecode(fromDb) ?? {});
|
||||
}
|
||||
|
||||
@override
|
||||
String mapToSql(value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return jsonEncode(value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user