one<T> method

  1. @override
Future<void> one<T>(
  1. T object, {
  2. String? subcollection,
})
override

Updates a document in Firestore with the given object.

Implementation

@override
Future<void> one<T>(T object, { String? subcollection }) async {
  final serializer = RDB.serializers[object.runtimeType];
  final String? className = RDB.classNames[object.runtimeType];

  if (serializer == null || className == null) {
    throw UnsupportedError('No serializer/class name 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(className, map["id"], subcollection: subcollection);
  DatabaseReference ref = RDB.instance.ref(path);
  await ref.update(map);
}