类:Mongo::Protocol::KillCursors::Upconverter

继承:
对象
  • 对象
显示全部
定义于:
lib/ Mongo/ 协议/kill_cursors.rb

Overview

将旧版插入消息转换为相应的 OP_COMMAND 样式消息。

由于:

  • 2.1.0

实例属性摘要折叠

实例方法摘要折叠

构造函数详情

#initialize (集合, cursor_ids) ⇒上转换

实例化上转换器。

例子:

实例化上转换器。

Upconverter.new('users', [ 1, 2, 3 ])

参数:

  • 集合 ( string )

    集合的名称。

  • cursor_id ( Array<Integer> )

    游标ID。

由于:

  • 2.1.0



100
101
102
103
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 100

def 初始化(集合, cursor_id)
  @collection = 集合
  @cursor_ids = cursor_id
end

实例属性详细信息

#集合string (只读)

返回 collection 集合的名称。

返回:

  • ( string )

    集合的名称。

由于:

  • 2.1.0



86
87
88
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 86

def 集合
  @collection
end

# cursor_idsArray<Integer> (只读)

返回 cursor_ids游标ID。

返回:

  • ( Array<Integer> )

    cursor_ids游标ID。

由于:

  • 2.1.0



89
90
91
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 89

def cursor_id
  @cursor_ids
end

实例方法详细信息

#commandBSON::Document

获取上转换命令。

例子:

获取命令。

upconverter.command

返回:

  • ( BSON::Document )

    上转换命令。

由于:

  • 2.1.0



113
114
115
116
117
118
119
120
121
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 113

def 命令
  文档 = BSON::文档.new
  文档.存储(' killCursors ', 集合)
  store_ids = cursor_id.map do |cursor_id|
    BSON::Int64.new(cursor_id)
  end
  文档.存储('cursors', store_ids)
  文档
end