collection method

CollectionRef collection(
  1. Type type, {
  2. String? subcollection,
})

Returns a reference to a collection using its class.

Implementation

CollectionRef collection(Type type, { String? subcollection }) {
  final String? className = LS.classNames[type];
  if (className == null) {
    throw UnsupportedError('No class name found for type: $type. Consider re-generating Firestorm data classes.');
  }
  if (subcollection != null) {
    return LS.instance.collection(className).doc(subcollection).collection(subcollection);
  }
  return LS.instance.collection(className);
}