Method: Moped::Protocol::Query#initialize

Defined in:
lib/moped/protocol/query.rb

#initialize(database, collection, selector, options = {}) ⇒ Query

Create a new query command.

Examples:

Query.new "moped", "users", { name: "John" },
  skip: 5,
  limit: 10,
  request_id: 12930,
  fields: { _id: -1, name: 1 }

Parameters:

  • database (String, Symbol)

    the database to insert into

  • collection (String, Symbol)

    the collection to insert into

  • selector (Hash)

    the query

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

    additional options

Options Hash (options):

  • :request_id (Number)

    the command’s request id

  • :skip (Number)

    the number of documents to skip

  • :limit (Number)

    the number of documents to return

  • :fields (Hash)

    the fields to return

  • :flags (Array)

    the flags for querying. Supported flags: :tailable, :slave_ok, :no_cursor_timeout, :await_data, :exhaust.



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/moped/protocol/query.rb', line 101

def initialize(database, collection, selector, options = {})
  @database = database
  @collection = collection

  @full_collection_name = "#{database}.#{collection}"
  @selector             = selector
  @request_id           = options[:request_id]
  @flags                = options[:flags]
  @limit                = options[:limit]
  @skip                 = options[:skip]
  @fields               = options[:fields]
end