(coll, spec, projection, skip, limit, batch_size,
                      options, read_concern=DEFAULT_READ_CONCERN,
                      collation=None)
return cmd
Generate a find command document.
Generate a find command document.
Generate a find command document .
def _gen_find_command(coll, spec, projection, skip, limit, batch_size,
                      options, read_concern=DEFAULT_READ_CONCERN,
                      collation=None):
    """Generate a find command document."""
    cmd = SON([('find', coll)])
    if '$query' in spec:
        cmd.update([(_MODIFIERS[key], val) if key in _MODIFIERS else (key, val)
                    for key, val in spec.items()])
        if '$explain' in cmd:
            cmd.pop('$explain')
        if '$readPreference' in cmd:
            cmd.pop('$readPreference')
    else:
        cmd['filter'] = spec

    if projection:
        cmd['projection'] = projection
    if skip:
        cmd['skip'] = skip
    if limit:
        cmd['limit'] = abs(limit)
        if limit < 0:
            cmd['singleBatch'] = True
    if batch_size:
        cmd['batchSize'] = batch_size
    if read_concern.level:
        cmd['readConcern'] = read_concern.document
    if collation:
        cmd['collation'] = collation

    if options:
        cmd.update([(opt, True)
                    for opt, val in _OPTIONS.items()
                    if options & val])
    return cmd
def _gen_find_command ( coll , spec , projection , skip , limit , batch_size , options , read_concern = DEFAULT_READ_CONCERN , collation = None ) : cmd = SON ( [ ( 'find' , coll ) ] ) if '$query' in spec : cmd . update ( [ ( _MODIFIERS [ key ] , val ) if key in _MODIFIERS else ( key , val ) for key , val in spec . items ( ) ] ) if '$explain' in cmd : cmd . pop ( '$explain' ) if '$readPreference' in cmd : cmd . pop ( '$readPreference' ) else : cmd [ 'filter' ] = spec if projection : cmd [ 'projection' ] = projection if skip : cmd [ 'skip' ] = skip if limit : cmd [ 'limit' ] = abs ( limit ) if limit < 0 : cmd [ 'singleBatch' ] = True if batch_size : cmd [ 'batchSize' ] = batch_size if read_concern . level : cmd [ 'readConcern' ] = read_concern . document if collation : cmd [ 'collation' ] = collation if options : cmd . update ( [ ( opt , True ) for opt , val in _OPTIONS . items ( ) if options & val ] ) return cmd