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

' upsert '.冻结

Result继承的常量

Result::CURSORResult::CURSOR_IDResult::FIRST_BATCHResult::NResult::NAMESPACEResult::NEXT_BATCHResult::OKResult::RESULT

实例属性摘要

Result继承的属性

#connection #connection_description #connection_global_id #context #replies

实例方法摘要折叠

Result继承的方法

#acknowledged? 、#cluster_time、 # cursor_id、#documents、# each 、# error # has_cursor_id ? , #initialize , #inspect , #labels , 命名空间 , #ok? , #operation_time , #reply , #returned_count , #snapshot_timestamp , # success ? #topology_version #validate! , #write_concern_error? , #liter_count

构造函数详情

该类从Mongo::Operation::Result继承了一个构造函数

实例方法详细信息

# 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



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

def 匹配计数
  return 0 除非 已确认?
  if upsert?
    0
  else
    n
  end
end

# Modified_count =" Integer "(整数)

获取已修改文档的数量。

例子:

获取修改后的计数。

result.modified_count

返回:

  • ( Integer )

    修改后的计数。

由于:

  • 2.0.0



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

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对象

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

took place.

例子:

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

result.upserted_id

返回:

  • ( Object )

    已更新或插入的 ID。

由于:

  • 2.0.0



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

def upserted_id
  return nil 除非 upsert?
  upsert?.first['_id']
end