whereById method

  1. @override
Future<T?> whereById(
  1. DocumentId docId
)
override

Get a document matching the document id

Implementation

@override
Future<T?> whereById(DocumentId docId) async {
  final snapshot = await ref
      .where(
        FieldPath.documentId,
        isEqualTo: docId.docId,
      )
      .get();

  final docs = snapshot.docs;

  if (docs.isEmpty) return null;

  return docs.first.data();
}