class Mongo::Operation::ListCollections::Result
Defines custom behavior of results when using the listCollections command.
@since 2.0.0 @api semiprivate
Public Instance Methods
Source
# File lib/mongo/operation/list_collections/result.rb, line 40 def cursor_id cursor_document ? cursor_document[CURSOR_ID] : super end
Get the cursor id for the result.
@example Get the cursor id.
result.cursor_id
@note Even though the wire protocol has a cursor_id
field for all
messages of type reply, it is always zero when using the listCollections command and must be retrieved from the cursor document itself.
@return [ Integer ] The cursor id.
@since 2.0.0 @api private
Mongo::Operation::Result#cursor_id
Source
# File lib/mongo/operation/list_collections/result.rb, line 67 def documents cursor_document[FIRST_BATCH] end
Get the documents for the listCollections result. It is the ‘firstBatch’
field in the 'cursor' field of the first document returned.
@example Get the documents.
result.documents
@return [ Array<BSON::Document> ] The documents.
@since 2.0.0 @api public
Source
# File lib/mongo/operation/list_collections/result.rb, line 53 def namespace cursor_document ? cursor_document[NAMESPACE] : super end
Get the namespace for the cursor.
@example Get the namespace.
result.namespace
@return [ String ] The namespace.
@since 2.0.0 @api private
Mongo::Operation::Result#namespace
Source
# File lib/mongo/operation/list_collections/result.rb, line 81 def validate! if successful? self else raise Error::OperationFailure.new( parser.message, self, code: parser.code, code_name: parser.code_name, labels: parser.labels, wtimeout: parser.wtimeout) end end
Validate the result. In the case where an unauthorized client tries to run the command we need to generate the proper error.
@example Validate the result.
result.validate!
@return [ Result
] Self if successful.
@since 2.0.0 @api private
Private Instance Methods
Source
# File lib/mongo/operation/list_collections/result.rb, line 97 def cursor_document @cursor_document ||= first_document[CURSOR] end
Source
# File lib/mongo/operation/list_collections/result.rb, line 101 def first_document @first_document ||= reply.documents[0] end