class Mongo::Protocol::Query
@api semipublic
parameters or the desired consistency and integrity the results.
There are a variety of flags that can be used to adjust cursor
number of returned documents.
select a subset of the fields, a number to skip or a limit on the
Users may also provide additional options such as a projection, to
to retrieve documents matching provided query.
This is a client request message that is sent to the server in order
MongoDB Wire protocol Query message.
def compress!(compressor, zlib_compression_level = nil)
- Since: - 2.5.0
Returns:
-
(Compressed, self)- A Protocol::Compressed message or self, depending on whether
Parameters:
-
zlib_compression_level(Integer) -- The zlib compression level to use. -
compressor(String, Symbol) -- The compressor to use.
def compress!(compressor, zlib_compression_level = nil) if compressor && compression_allowed?(selector.keys.first) Compressed.new(self, compressor, zlib_compression_level) else self end end
def determine_limit
def determine_limit [ @options[:limit] || @options[:batch_size], @options[:batch_size] || @options[:limit] ].min || 0 end
def initialize(database, collection, selector, options = {})
(**options)-
:flags(Array) -- The flags for the query message. -
:limit(Integer) -- The number of documents to return. -
:skip(Integer) -- The number of documents to skip. -
:project(Hash) -- The projection.
Parameters:
-
options(Hash) -- The additional query options. -
selector(Hash) -- The query selector. -
collection(String, Symbol) -- The collection to query. -
database(String, Symbol) -- The database to query.
Other tags:
- Example: Find all user ids. -
Example: Find all users with slave ok bit set -
Example: Find all users named Tyler skipping 5 and returning 10. -
Example: Find all users named Tyler. -
def initialize(database, collection, selector, options = {}) @database = database @namespace = "#{database}.#{collection}" @selector = selector @options = options @project = options[:project] @limit = determine_limit @skip = options[:skip] || 0 @flags = options[:flags] || [] @upconverter = Upconverter.new(collection, selector, options, flags) super end
def payload
- Since: - 2.1.0
Returns:
-
(BSON::Document)- The event payload.
Other tags:
- Example: Return the event payload. -
def payload BSON::Document.new( command_name: upconverter.command_name, database_name: @database, command: upconverter.command, request_id: request_id ) end
def replyable?
- Since: - 2.0.0
Returns:
-
(true)- Always true for queries.
Other tags:
- Example: Does the message require a reply? -
def replyable? true end