documentFromObject method

DatabaseReference documentFromObject(
  1. dynamic object, {
  2. String? subcollection,
})

Returns a reference to a document using an object.

Implementation

DatabaseReference documentFromObject(dynamic object, { String? subcollection }) {
  if (object == null) {
    throw NullIDException("Cannot get document reference from null object");
  }
  final String? className = RDB.classNames[object.runtimeType];
  if (className == null) {
    throw UnsupportedError('No class name found for type: ${object.runtimeType}. Consider re-generating Firestorm data classes.');
  }

  return RDB.instance.ref(RDB.constructPathForClassAndID(className, object.id, subcollection: subcollection));
}