one<T> method

  1. @override
Future<bool> one<T>(
  1. dynamic object, {
  2. String? subcollection,
  3. GetOptions? getOptions,
})
override

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

Implementation

@override
Future<bool> one<T>(dynamic object, { String? subcollection, GetOptions? getOptions }) async {
  if (object.id == null) {
    return false;
  }
  final String? className = FS.classNames[T];
  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(object.id);
  if (subcollection != null) {
    ref = FS.instance.collection(className).doc(subcollection).collection(subcollection).doc(object.id);
  }
  DocumentSnapshot snapshot = await ref.get(getOptions);
  return snapshot.exists;
}