Method: Mongo::Grid::FSBucket#find

Defined in:
lib/mongo/grid/fs_bucket.rb

#find(selector = nil, options = {}) ⇒ CollectionView

Find files collection documents matching a given selector.

Examples:

Find files collection documents by a filename.

fs.find(filename: 'file.txt')

Parameters:

  • selector (Hash) (defaults to: nil)

    The selector to use in the find.

  • options (Hash) (defaults to: {})

    The options for the find.

Options Hash (options):

  • :allow_disk_use (true, false)

    Whether the server can write temporary data to disk while executing the find operation.

  • :batch_size (Integer)

    The number of documents returned in each batch of results from MongoDB.

  • :limit (Integer)

    The max number of docs to return from the query.

  • :no_cursor_timeout (true, false)

    The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.

  • :skip (Integer)

    The number of docs to skip before returning results.

  • :sort (Hash)

    The key and direction pairs by which the result set will be sorted.

Returns:

  • (CollectionView)

    The collection view.

Since:

  • 2.1.0



134
135
136
137
# File 'lib/mongo/grid/fs_bucket.rb', line 134

def find(selector = nil, options = {})
  opts = options.merge(read: read_preference) if read_preference
  files_collection.find(selector, opts || options)
end