one<T> method
- T object, {
- String? subcollection,
Updates a document in Firestore with the given object.
Implementation
Future<void> one<T>(T object, { String? subcollection }) async {
final serializer = RDB.serializers[object.runtimeType];
if (serializer == null) {
throw UnsupportedError('No serializer found for type: ${object.runtimeType}. Consider re-generating Firestorm data classes.');
}
final map = serializer(object);
if (map["id"].isEmpty) {
throw NullIDException(map);
}
final String path = RDB.constructPathForClassAndID(object.runtimeType, map["id"], subcollection: subcollection);
DatabaseReference ref = RDB.instance.ref(path);
await ref.update(map);
}