类:Mongo::Operation::Update::Result

继承:
操作::结果
  • 对象
显示全部
定义于:
lib/ Mongo/operation/ 更新/result.rb

Overview

定义更新结果的自定义行为。

由于:

  • 2.0.0

常量摘要折叠

已修改 =

此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。

结果中已修改Docs字段的数量。

由于:

  • 2.0.0

'nModified'
UPSERTED =

此常量是私有 API 的一部分。 应尽可能避免使用此常量,因为它将来可能会被删除或更改。

结果中更新或插入的Docs字段。

由于:

  • 2.0.0

'更新或插入'

实例方法摘要折叠

实例方法详细信息

# bulk_result对象

由于:

  • 2.0.0



101
102
103
# File 'lib/ Mongo/operation/ 更新/result.rb', line 101

def bulk_result
  BulkResult.new(@replies, connection_description)
end

#matched_count整数

获取匹配的文档数量。

例子:

获取匹配的计数。

result.matched_count

返回:

  • ( Integer )

    匹配的计数。

由于:

  • 2.0.0



46
47
48
49
50
51
52
53
54
# File 'lib/ Mongo/operation/ 更新/result.rb', line 46

def 匹配计数
  return 0 除非 已确认?

  if upsert?
    0
  else
    n
  end
end

# Modified_count =" Integer "(整数)

获取已修改文档的数量。

例子:

获取修改后的计数。

result.modified_count

返回:

  • ( Integer )

    修改后的计数。

由于:

  • 2.0.0



65
66
67
68
69
# File 'lib/ Mongo/operation/ 更新/result.rb', line 65

def Modified_count
  return 0 除非 已确认?

  first[MODIFIED]
end

#upserted_countInteger

返回已更新或插入的文档数。

例子:

获取已更新或插入的文档数量。

result.upserted_count

返回:

  • ( Integer )

    更新或插入的数字。

由于:

  • 2.4.2



96
97
98
# File 'lib/ Mongo/operation/ 更新/result.rb', line 96

def upserted_count
  upsert? ? n : 0
end

# upserted_id对象

所插入文档的标识符(如果进行更新或插入)。

例子:

获取已更新或插入文档的标识符。

result.upserted_id

返回:

  • ( Object )

    已更新或插入的 ID。

由于:

  • 2.0.0



81
82
83
84
85
# File 'lib/ Mongo/operation/ 更新/result.rb', line 81

def upserted_id
  return nil 除非 upsert?

  upsert?.first['_id']
end