one<T> method
Checks if a document exists in Localstore using its type and ID.
Implementation
@override
Future<bool> one<T>(dynamic object, { String? subcollection }) async {
if (object.id == null) {
return false;
}
final String? className = LS.classNames[object.runtimeType];
if (className == null) {
throw UnsupportedError('No class name found for type: $className. Consider re-generating Firestorm data classes.');
}
DocumentRef ref = LS.instance.collection(className).doc(object.id);
if (subcollection != null) {
ref = LS.instance.collection(className).doc(subcollection).collection(subcollection).doc(object.id);
}
Map<String, dynamic>? data = await ref.get();
return data != null;
}