$buildCommand method

  1. @override
Map<String, Object> $buildCommand()

Implementation

@override
Map<String, Object> $buildCommand() {
  if (collection!.collectionName == r'$cmd' &&
      filter != null &&
      limit != null &&
      limit! == 1) {
    return <String, Object>{
      for (var key in filter!.keys) key: filter![key] ?? ''
    };
  }
  return <String, Object>{
    keyFind: collection!.collectionName,
    if (filter != null) keyFilter: filter!,
    if (sort != null) keySort: sort!,
    if (projection != null) keyProjection: projection!,
    if (hint != null)
      keyHint: hint!
    else if (hintDocument != null)
      keyHint: hintDocument!,
    if (skip != null && skip! > 0) keySkip: skip!,
    if (limit != null && limit! > 0) keyLimit: limit!,
  };
}