findOne method
Returns one document that satisfies the specified query criteria on the collection or view. If multiple documents satisfy the query, this method returns the first document.
Implementation
Future<Map<String, dynamic>?> findOne([selector]) {
if (db._masterConnectionVerified.serverCapabilities.supportsOpMsg) {
if (selector is SelectorBuilder) {
return modernFindOne(selector: selector);
} else if (selector is Map<String, dynamic>) {
return modernFindOne(filter: selector);
} else if (selector == null) {
return modernFindOne();
}
throw MongoDartError('The selector parameter should be either a '
'SelectorBuilder or a Map<String, dynamic>');
}
return legacyFindOne(selector);
}