Class: Mongo::Protocol::GetMore

Inherits:
Message
  • Object
show all
Defined in:
build/ruby-driver-v2.19/lib/mongo/protocol/get_more.rb

Overview

MongoDB Wire protocol getMore message.

This is a client request message that is sent to the server in order to retrieve additional documents from a cursor that has already been instantiated.

The operation requires that you specify the database and collection name as well as the cursor id because cursors are scoped to a namespace.

Defined Under Namespace

Classes: Upconverter

Constant Summary

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

#request_id

Instance Method Summary collapse

Methods inherited from Message

#==, deserialize, #hash, #maybe_add_server_api, #maybe_compress, #maybe_decrypt, #maybe_encrypt, #maybe_inflate, #number_returned, #serialize, #set_request_id

Methods included from Id

included

Constructor Details

#initialize(database, collection, number_to_return, cursor_id) ⇒ GetMore

Creates a new getMore message

Examples:

Get 15 additional documents from cursor 123 in ‘xgen.users’.

GetMore.new('xgen', 'users', 15, 123)

Parameters:

  • database (String, Symbol)

    The database to query.

  • collection (String, Symbol)

    The collection to query.

  • number_to_return (Integer)

    The number of documents to return.

  • cursor_id (Integer)

    The cursor id returned in a reply.



42
43
44
45
46
47
48
49
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/get_more.rb', line 42

def initialize(database, collection, number_to_return, cursor_id)
  @database = database
  @namespace = "#{database}.#{collection}"
  @number_to_return = number_to_return
  @cursor_id = cursor_id
  @upconverter = Upconverter.new(collection, cursor_id, number_to_return)
  super
end

Instance Method Details

#payloadBSON::Document

Return the event payload for monitoring.

Examples:

Return the event payload.

message.payload

Returns:

  • (BSON::Document)

    The event payload.

Since:

  • 2.1.0



59
60
61
62
63
64
65
66
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/get_more.rb', line 59

def payload
  BSON::Document.new(
    command_name: 'getMore',
    database_name: @database,
    command: upconverter.command,
    request_id: request_id
  )
end

#replyable?true

Get more messages require replies from the database.

Examples:

Does the message require a reply?

message.replyable?

Returns:

  • (true)

    Always true for get more.

Since:

  • 2.0.0



76
77
78
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/get_more.rb', line 76

def replyable?
  true
end