mongo-ruby-driver/lib/mongo/message/query_message.rb

27 lines
587 B
Ruby
Raw Normal View History

2008-11-22 01:00:51 +00:00
require 'mongo/message/message'
require 'mongo/message/opcodes'
module XGen
module Mongo
module Driver
class QueryMessage < Message
def initialize(db_name, collection_name, query)
2008-11-22 01:00:51 +00:00
super(OP_QUERY)
write_int(0)
write_string("#{db_name}.#{collection_name}")
2008-11-22 01:00:51 +00:00
write_int(query.number_to_skip)
write_int(query.number_to_return)
write_doc(query.selector)
write_doc(query.fields) if query.fields
end
def first_key(key)
@first_key = key
end
2008-11-22 01:00:51 +00:00
end
end
end
end