documentFromID method

DatabaseReference documentFromID(
  1. Type type,
  2. String documentID, {
  3. String? subcollection,
})

Returns a reference to a document using its class and document ID.

Implementation

DatabaseReference documentFromID(Type type, String documentID, { String? subcollection }) {
  if (documentID.isEmpty) {
    throw NullIDException("Cannot get document reference from an empty ID");
  }
  final String? className = RDB.classNames[type];
  if (className == null) {
    throw UnsupportedError('No class name found for type: $type. Consider re-generating Firestorm data classes.');
  }
  return RDB.instance.ref(RDB.constructPathForClassAndID(className, documentID, subcollection: subcollection));
}