Document<T>.fromJson constructor
Document<T>.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Document.fromJson(Map<String, dynamic> json) {
// Handle collection being either a String or a Map
dynamic collectionValue = json['collection'];
return Document<T>(
id: json['id'],
collection: collectionValue,
data: json['data'] as T,
createdAt: DateTime.parse(json['created_at']),
updatedAt: json['updated_at'] == null
? DateTime.parse(json['created_at'])
: DateTime.parse(json['updated_at']),
);
}