模块:Mongoid::Association::Referenced::HasMany::Buildable
- 定义于:
- lib/mongoid/association/referenced/has_many/buildable.rb
Overview
has_many 关联的 Builder 行为。
实例方法摘要折叠
-
# build (base, object, _type = nil, Selected_fields = nil) ⇒ 文档
此方法接受_id或对象,并使用该ID查询反向面或设置该对象。
实例方法详细信息
# 构建 (base, 对象, _type = nil, Selected_fields = nil) ⇒文档
此方法接受_id或对象,并使用该ID查询反向面或设置该对象。
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mongoid/association/referenced/has_many/buildable.rb', line 21 def 构建(基础, 对象, _type = nil, created_fields = nil) return 对象 || [] 除非 查询?(对象) # 处理 $lookup聚合中的数组哈希 if 对象.is_a?(阵列) && 对象.全部? { |o| o.is_a?(哈希) } return 对象.map do |attrs| 工厂.execute_from_db(klass, attrs, nil, created_fields, execute_callbacks: false) end end return [] if 对象.is_a?(阵列) query_criteria(对象, 基础) end |