oneWithID<T> method

  1. @override
Future<bool> oneWithID<T>(
  1. Type type,
  2. String documentID, {
  3. String? subcollection,
  4. GetOptions? getOptions,
})
override

Checks if a document exists in Firestore using its type and ID.

Implementation

@override
Future<bool> oneWithID<T>(Type type, String documentID, { String? subcollection, GetOptions? getOptions }) async {
  final String? className = FS.classNames[type];
  if (className == null) {
    throw UnsupportedError('No class name found for type: $className. Consider re-generating Firestorm data classes.');
  }
  DocumentReference ref = FS.instance.collection(className).doc(documentID);
  if (subcollection != null) {
    ref = FS.instance.collection(className).doc(subcollection).collection(subcollection).doc(documentID);
  }
  DocumentSnapshot snapshot = await ref.get(getOptions);
  return snapshot.exists;
}