My flutter app needs to count for unread messages. So far, when a message is created, no 'readDate' field is set.
Is it possible to have a where condition that tests the presence of the field?
final snapshot = await FirebaseFirestore.instance
.collection(collectionName)
.where("toUserId", isEqualTo: userId)
//.where("unreadDate", isGreaterThan: 0). //<< Error
//.where("unreadDate", isNull: true)
.orderBy("creationDate", descending: true)
.limit(limit)
.withConverter<ClassifiedAdMessage>(
fromFirestore: (snapshot, _) =>
ClassifiedAdMessage.fromMap(snapshot.data()!),
toFirestore: (message, _) => message.toMap(),
)
.get();