Class: Mongo::Protocol::Query
- Includes:
- Monitoring::Event::Secure
- Defined in:
- lib/mongo/protocol/query.rb
Overview
MongoDB Wire protocol Query message.
This is a client request message that is sent to the server in order to retrieve documents matching provided query.
Users may also provide additional options such as a projection, to select a subset of the fields, a number to skip or a limit on the number of returned documents.
There are a variety of flags that can be used to adjust cursor parameters or the desired consistency and integrity the results.
Defined Under Namespace
Classes: Upconverter
Constant Summary
Constants included from Monitoring::Event::Secure
Monitoring::Event::Secure::REDACTED_COMMANDS
Constants inherited from Message
Message::BATCH_SIZE, Message::COLLECTION, Message::LIMIT, Message::MAX_MESSAGE_SIZE, Message::ORDERED, Message::Q
Instance Attribute Summary
Attributes inherited from Message
Instance Method Summary collapse
-
#compress!(compressor, zlib_compression_level = nil) ⇒ Compressed, self
Compress this message.
-
#initialize(database, collection, selector, options = {}) ⇒ Query
constructor
Creates a new Query message.
-
#payload ⇒ BSON::Document
Return the event payload for monitoring.
-
#replyable? ⇒ true
Query messages require replies from the database.
Methods included from Monitoring::Event::Secure
#compression_allowed?, #redacted
Methods inherited from Message
#==, deserialize, #hash, #inflate!, #number_returned, #serialize, #set_request_id
Constructor Details
#initialize(database, collection, selector, options = {}) ⇒ Query
Creates a new Query message
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mongo/protocol/query.rb', line 61 def initialize(database, collection, selector, = {}) @database = database @namespace = "#{database}.#{collection}" @selector = selector = @project = [:project] @limit = determine_limit @skip = [:skip] || 0 @flags = [:flags] || [] @upconverter = Upconverter.new(collection, selector, , flags) super end |
Instance Method Details
#compress!(compressor, zlib_compression_level = nil) ⇒ Compressed, self
Compress this message.
112 113 114 115 116 117 118 |
# File 'lib/mongo/protocol/query.rb', line 112 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 |
#payload ⇒ BSON::Document
Return the event payload for monitoring.
82 83 84 85 86 87 88 89 |
# File 'lib/mongo/protocol/query.rb', line 82 def payload BSON::Document.new( command_name: upconverter.command_name, database_name: @database, command: upconverter.command, request_id: request_id ) end |
#replyable? ⇒ true
Query messages require replies from the database.
99 100 101 |
# File 'lib/mongo/protocol/query.rb', line 99 def replyable? true end |