Class: Monga::Protocol::Query
- Defined in:
- lib/monga/protocol/query.rb
Constant Summary collapse
- FLAGS =
{ tailable_cursor: 1, slave_ok: 2, no_cursor_timeout: 4, await_data: 5, exhaust: 6, partial: 7, }
Constants inherited from Request
Instance Attribute Summary
Attributes inherited from Request
Instance Method Summary collapse
Methods inherited from Request
#callback_perform, #command, #header, #initialize, #parse_response, #perform
Constructor Details
This class inherits a constructor from Monga::Request
Instance Method Details
#body ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/monga/protocol/query.rb', line 14 def body @body ||= begin skip = [:skip] || 0 limit = get_limit selector = [:selector] || {} query = {} query["$query"] = [:query] || {} query["$hint"] = [:hint] if [:hint] query["$orderby"] = [:sort] if [:sort] query["$explain"] = [:explain] if [:explain] msg = ::BinUtils.append_int32_le!(nil, flags) msg << full_name << Monga::NULL_BYTE ::BinUtils.append_int32_le!(msg, skip, limit) msg << query.to_bson msg << selector.to_bson if selector.any? msg end end |