one<T> method
Reads a document from Firestore and converts it to the specified type.
Implementation
Future<T?> one<T>(String documentID, { String? subcollection }) async {
final deserializer = RDB.deserializers[T];
if (deserializer == null) {
throw UnsupportedError('No deserializer found for type: $T. Consider re-generating Firestorm data classes.');
}
String path = RDB.constructPathForClassAndID(T, documentID, subcollection: subcollection);
DataSnapshot snapshot = await RDB.instance.ref(path).get();
if (snapshot.exists) {
final Map<String, dynamic> data = RDBDeserializationHelper.snapshotToMap(snapshot);
return deserializer(data) as T;
}
return null;
}