modernFind method

Stream<Map<String, dynamic>> modernFind({
  1. SelectorBuilder? selector,
  2. Map<String, dynamic>? filter,
  3. Map<String, Object>? sort,
  4. Map<String, Object>? projection,
  5. String? hint,
  6. Map<String, Object>? hintDocument,
  7. int? skip,
  8. int? limit,
  9. FindOptions? findOptions,
  10. Map<String, Object>? rawOptions,
})

Implementation

Stream<Map<String, dynamic>> modernFind(
    {SelectorBuilder? selector,
    Map<String, dynamic>? filter,
    Map<String, Object>? sort,
    Map<String, Object>? projection,
    String? hint,
    Map<String, Object>? hintDocument,
    int? skip,
    int? limit,
    FindOptions? findOptions,
    Map<String, Object>? rawOptions}) {
  if (!db.masterConnection.serverCapabilities.supportsOpMsg) {
    throw MongoDartError('At least MongoDb version 3.6 is required '
        'to run the find operation');
  }
  var sortMap = sort;
  if (sortMap == null && selector?.map[keyOrderby] != null) {
    sortMap = <String, Object>{...selector!.map[keyOrderby]};
  }

  var operation = FindOperation(this,
      filter:
          filter ?? (selector?.map == null ? null : selector!.map[key$Query]),
      sort: sortMap,
      projection: projection ?? selector?.paramFields,
      hint: hint,
      hintDocument: hintDocument,
      limit: limit ?? selector?.paramLimit,
      skip: skip ??
          (selector != null && selector.paramSkip > 0
              ? selector.paramSkip
              : null),
      findOptions: findOptions,
      rawOptions: rawOptions);

  return ModernCursor(operation).stream;
}