类:Mongoid::Criteria::Queryable::Options
- 定义于:
- lib/mongoid/criteria/queryable/options.rb
Overview
选项是传递给 MongoDB 查询的选项的哈希表示,例如跳过、限制和排序条件。
实例属性摘要
从Smash继承的属性
#aliased_associations 、 #aliased_associations aliased_associations。 、 #aliases 、 #aliases 别名。 、 #associations 、 #associations 关联。 、 #serializers 、 #serializers 序列化器。
实例方法摘要折叠
-
#__deep_copy__ ⇒ Options
执行选项的深度复制。
-
#个字段⇒ 哈希
获取字段选项的便捷方法。
-
# limit ⇒ 整数
获取限制选项的便捷方法。
-
#skip ⇒ Integer
获取跳过选项的便捷方法。
-
#sort ⇒ Hash
获取排序选项的便捷方法。
-
# 存储 (key, value, localize = true) ⇒ 对象(也:#[]=)
将值存储在所提供键的选项中。
-
#to_pipeline ⇒ Array<Hash>
将选项转换为聚合管道友好选项。
从Smash继承的方法
构造函数详情
该类从Mongoid::Criteria::Queryable::Smash继承构造函数
实例方法详细信息
# __deep_copy__ ⇒选项
执行选项的深度复制。
87 88 89 90 91 92 93 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 87 def __deep_copy__ self.class.new(别名, 序列化器, 关联, aliased_associations) do |copy| each_pair do |key, 值| copy.合并!(key => 值.__deep_copy__) end end end |
#个字段⇒哈希
获取字段选项的便捷方法。
18 19 20 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 18 def 字段 self[:fields] end |
# limit ⇒整数
获取限制选项的便捷方法。
28 29 30 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 28 def limit self[:limit] end |
# skip ⇒整数
获取跳过选项的便捷方法。
38 39 40 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 38 def 跳过 self[:skip] end |
#sort ⇒ Hash
获取排序选项的便捷方法。
48 49 50 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 48 def sort self[:sort] end |
# store (key, value, localize = true) ⇒ Object也称为: []=
将值存储在所提供键的选项中。 这些选项将在此步骤中处理所有必要的序列化和本地化。
62 63 64 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 62 def 存储(key, 值, localize = true) 超(key, 发展(值, localize)) end |
# to_pipeline ⇒ Array<Hash>
将选项转换为聚合管道友好选项。
73 74 75 76 77 78 79 |
# File 'lib/mongoid/criteria/queryable/options.rb', line 73 def to_pipeline 管道 = [] 管道.推动({ " $skip " => 跳过 }) if 跳过 管道.推动({ " $limit " => limit }) if limit 管道.推动({ " $sort " => sort }) if sort 管道 end |