模块:Mongo::Operation::Result::Aggregatable Private

定义于:
lib/ Mongo/operation/shared/result/aggregatable.rb

Overview

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

定义批量写入结果的自定义行为

由于:

  • 2.0.0

实例方法摘要折叠

实例方法详细信息

#aggregate_write_concern_errors (count) ⇒数组

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

聚合从此结果返回的写关注错误。

例子:

聚合写关注错误。

result.aggregate_write_concern_errors(100)

参数:

  • 数数 ( Integer )

    已执行的文档数量。

返回:

  • ( Array )

    聚合写关注(write concern)错误。

由于:

  • 2.0.0



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ Mongo/operation/shared/result/aggregatable.rb', line 58

def aggregate_write_concern_errors(数数)
  return 除非 @replies

  @replies.each_with_index.化简(reduce)(nil) do |errors, (回复, _)|
    来年 除非 write_concern_errors = 回复.文档.first[' writeConcernErrors ']

    (errors || []) << write_concern_errors.化简(reduce)(nil) do |errs, wce|
      wce.合并!(' index ' => 数数 + wce[' index '])
      (errs || []) << write_concern_error
    end
  end
end

#aggregate_write_errors (count) ⇒数组

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

聚合从此结果返回的写入错误。

例子:

聚合写入错误。

result.aggregate_write_errors(0)

参数:

  • 数数 ( Integer )

    已执行的文档数量。

返回:

  • ( Array )

    聚合写入错误。

由于:

  • 2.0.0



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ Mongo/operation/shared/result/aggregatable.rb', line 35

def aggregate_write_errors(数数)
  return 除非 @replies

  @replies.化简(reduce)(nil) do |errors, 回复|
    来年 除非 write_errors = 回复.文档.first[' writeErrors ']

    wes = write_errors.收集 do |我们|
      我们.合并!(' index ' => 数数 + 我们[' index '])
    end
    (errors || []) << wes if wes
  end
end