existId method
Checks if a document with the given ID exists in the collection.
The idField
should be a valid MongoDB ObjectId string.
Returns true
if the document exists, otherwise false
.
Implementation
Future<bool> existId(String idField) async {
var id = ObjectId.tryParse(idField);
if (id == null) return false;
var count = await collection.modernCount(selector: where.id(id));
return count.count > 0;
}