类: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



106
107
108
109
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 106

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

实例属性详细信息

#集合string (只读)

返回 collection 集合的名称。

返回:

  • ( string )

    集合的名称。

由于:

  • 2.1.0



92
93
94
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 92

def 集合
  @collection
end

# cursor_idsArray<Integer> (只读)

返回 cursor_ids游标ID。

返回:

  • ( Array<Integer> )

    cursor_ids游标ID。

由于:

  • 2.1.0



95
96
97
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 95

def cursor_id
  @cursor_ids
end

实例方法详细信息

#commandBSON::Document

获取上转换命令。

例子:

获取命令。

upconverter.command

返回:

  • ( BSON::Document )

    上转换命令。

由于:

  • 2.1.0



119
120
121
122
123
124
125
126
127
# File 'lib/ Mongo/ 协议/kill_cursors.rb', line 119

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