Class: Moped::Protocol::GetMore

Inherits:
Object
  • Object
show all
Includes:
Message
Defined in:
lib/moped/protocol/get_more.rb

Overview

The Protocol class for retrieving more documents from a cursor.

Examples:

Get more results using database default limit

insert = GetMore.new "moped", "people", 29301021, 0

Get more results using custom limit

insert = Insert.new "moped", "people", 29301021, 10

Setting the request id

insert = Insert.new "moped", "people", 29301021, 10,
  request_id: 123

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Message

included, #inspect, #serialize

Constructor Details

#initialize(database, collection, cursor_id, limit, options = {}) ⇒ GetMore

Create a new GetMore command. The database and collection arguments are joined together to set the full_collection_name.

Examples:

GetMore.new "moped", "users", 29301021, 10, request_id: 123


65
66
67
68
69
70
71
72
73
# File 'lib/moped/protocol/get_more.rb', line 65

def initialize(database, collection, cursor_id, limit, options = {})
  @database   = database
  @collection = collection

  @full_collection_name = "#{database}.#{collection}"
  @cursor_id            = cursor_id
  @limit                = limit
  @request_id           = options[:request_id]
end

Instance Attribute Details

#collectionString, Symbol (readonly)

Returns the collection this insert targets.

Returns:



58
59
60
# File 'lib/moped/protocol/get_more.rb', line 58

def collection
  @collection
end

#cursor_idNumber

Returns the id of the cursor to get more documents from.

Returns:

  • (Number)

    the id of the cursor to get more documents from



44
# File 'lib/moped/protocol/get_more.rb', line 44

int64    :cursor_id

#databaseString, Symbol (readonly)

Returns the database this insert targets.

Returns:



55
56
57
# File 'lib/moped/protocol/get_more.rb', line 55

def database
  @database
end

#full_collection_nameString

Returns the namespaced collection name.

Returns:

  • (String)

    the namespaced collection name



36
# File 'lib/moped/protocol/get_more.rb', line 36

cstring  :full_collection_name

#lengthNumber

Returns the length of the message.

Returns:

  • (Number)

    the length of the message



20
# File 'lib/moped/protocol/get_more.rb', line 20

int32 :length

#limitNumber

Returns the number of documents to return.

Returns:

  • (Number)

    the number of documents to return



40
# File 'lib/moped/protocol/get_more.rb', line 40

int32    :limit

#op_codeNumber

Returns OP_GETMORE operation code (2005).

Returns:

  • (Number)

    OP_GETMORE operation code (2005)



30
# File 'lib/moped/protocol/get_more.rb', line 30

int32 :op_code

#request_idNumber

Returns the request id of the message.

Returns:

  • (Number)

    the request id of the message



24
# File 'lib/moped/protocol/get_more.rb', line 24

int32 :request_id

Instance Method Details

#log_inspectObject



75
76
77
78
# File 'lib/moped/protocol/get_more.rb', line 75

def log_inspect
  type = "GET_MORE"
  "%-12s database=%s collection=%s limit=%s cursor_id=%s" % [type, database, collection, limit, cursor_id]
end

#receive_replies(connection) ⇒ Protocol::Reply

Receive replies to the message.

Examples:

Receive replies.

message.receive_replies(connection)

Parameters:

Returns:

Since:

  • 1.0.0



90
91
92
# File 'lib/moped/protocol/get_more.rb', line 90

def receive_replies(connection)
  connection.read
end